Skip to content

Commit

Permalink
(iOS) Revert "co-existence with cordova-plugin-local-notification on …
Browse files Browse the repository at this point in the history
…iOS"

Upon testing, this plugin does not work with `cordova-plugin-local-notification` present in the same project even with this code in place.
Therefore removing it should stop the crashes occurring in #385.
And the conflict between the 2 plugins will need to be addressed separately under #230.

This reverts commit 4e9a0f4:

> co-existence with cordova-plugin-local-notification on iOS

> Local notifications on iOS via cordova-plugin-local-notification are working again.
>Click-callback for remote notifications not working right now.

>Details:
>UNUserNotificationCenter accepts a single delegate that handles the display of notifications. cordova-plugin-firebase now stores a reference to the existing delegate if any and proxies the delegate-calls (cordova-plugin-local-notification is >already doing that in the other direction when applicable).
  • Loading branch information
Dave Alden committed Aug 13, 2020
1 parent 8b5d45d commit 935b8ab
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions src/ios/AppDelegate+FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ @interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegat
@end

#define kApplicationInBackgroundKey @"applicationInBackground"
#define kDelegateKey @"delegate"

@implementation AppDelegate (FirebasePlugin)

Expand All @@ -28,14 +27,6 @@ + (AppDelegate*) instance {
static bool authStateChangeListenerInitialized = false;
static bool shouldEstablishDirectChannel = false;

- (void)setDelegate:(id)delegate {
objc_setAssociatedObject(self, kDelegateKey, delegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (id)delegate {
return objc_getAssociatedObject(self, kDelegateKey);
}

+ (void)load {
Method original = class_getInstanceMethod(self, @selector(application:didFinishLaunchingWithOptions:));
Method swizzled = class_getInstanceMethod(self, @selector(application:swizzledDidFinishLaunchingWithOptions:));
Expand Down Expand Up @@ -108,10 +99,6 @@ - (BOOL)application:(UIApplication *)application swizzledDidFinishLaunchingWithO
[FirebasePlugin.firebasePlugin handlePluginExceptionWithoutContext:exception];
}
}];

// Set UNUserNotificationCenter delegate
self.delegate = [UNUserNotificationCenter currentNotificationCenter].delegate;
[UNUserNotificationCenter currentNotificationCenter].delegate = self;

// Set NSNotificationCenter observer
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:)
Expand Down Expand Up @@ -394,14 +381,6 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {

@try{
if(center == nil){
center = [UNUserNotificationCenter currentNotificationCenter];
}
if(center != nil){
[self.delegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}

if (![notification.request.trigger isKindOfClass:UNPushNotificationTrigger.class] && ![notification.request.trigger isKindOfClass:UNTimeIntervalNotificationTrigger.class]){
[FirebasePlugin.firebasePlugin _logError:@"willPresentNotification: aborting as not a supported UNNotificationTrigger"];
Expand Down Expand Up @@ -470,14 +449,6 @@ - (void) userNotificationCenter:(UNUserNotificationCenter *)center
withCompletionHandler:(void (^)(void))completionHandler
{
@try{
if(center == nil){
center = [UNUserNotificationCenter currentNotificationCenter];
}
if(center != nil){
[self.delegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}

if (![response.notification.request.trigger isKindOfClass:UNPushNotificationTrigger.class] && ![response.notification.request.trigger isKindOfClass:UNTimeIntervalNotificationTrigger.class]){
[FirebasePlugin.firebasePlugin _logMessage:@"didReceiveNotificationResponse: aborting as not a supported UNNotificationTrigger"];
Expand Down

0 comments on commit 935b8ab

Please sign in to comment.