Skip to content

Commit

Permalink
chore(ios): update all NSLog to include [PushPlugin] prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Sep 17, 2024
1 parent 84731dd commit 567552a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 58 deletions.
34 changes: 16 additions & 18 deletions src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"didReceiveNotification with fetchCompletionHandler");
NSLog(@"[PushPlugin] didReceiveNotification with fetchCompletionHandler");

// app is in the background or inactive, so only call notification callback if this is a silent push
if (application.applicationState != UIApplicationStateActive) {

NSLog(@"app in-active");
NSLog(@"[PushPlugin] app in-active");

// do some convoluted logic to find out if this should be a silent push.
long silent = 0;
Expand All @@ -97,7 +97,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
}

if (silent == 1) {
NSLog(@"this should be a silent push");
NSLog(@"[PushPlugin] this should be a silent push");
void (^safeHandler)(UIBackgroundFetchResult) = ^(UIBackgroundFetchResult result){
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(result);
Expand All @@ -112,19 +112,18 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N

id notId = [userInfo objectForKey:@"notId"];
if (notId != nil) {
NSLog(@"Push Plugin notId %@", notId);
NSLog(@"[PushPlugin] notId %@", notId);
[pushHandler.handlerObj setObject:safeHandler forKey:notId];
} else {
NSLog(@"Push Plugin notId handler");
NSLog(@"[PushPlugin] notId handler");
[pushHandler.handlerObj setObject:safeHandler forKey:@"handler"];
}

pushHandler.notificationMessage = userInfo;
pushHandler.isInline = NO;
[pushHandler notificationReceived];
} else {
NSLog(@"just put it in the shade");
//save it for later
NSLog(@"[PushPlugin] Save push for later");
self.launchNotification = userInfo;
completionHandler(UIBackgroundFetchResultNewData);
}
Expand Down Expand Up @@ -152,13 +151,12 @@ - (void)checkUserHasRemoteNotificationsEnabledWithCompletionHandler:(nonnull voi
}

- (void)pushPluginOnApplicationDidBecomeActive:(NSNotification *)notification {
NSLog(@"[PushPlugin] pushPluginOnApplicationDidBecomeActive");

NSLog(@"active");

NSString *firstLaunchKey = @"firstLaunchKey";
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"phonegap-plugin-push"];
if (![defaults boolForKey:firstLaunchKey]) {
NSLog(@"application first launch: remove badge icon number");
NSLog(@"[PushPlugin] application first launch: remove badge icon number");
[defaults setBool:YES forKey:firstLaunchKey];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
Expand All @@ -167,11 +165,11 @@ - (void)pushPluginOnApplicationDidBecomeActive:(NSNotification *)notification {

PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
if (pushHandler.clearBadge) {
NSLog(@"PushPlugin clearing badge");
NSLog(@"[PushPlugin] clearing badge");
//zero badge
application.applicationIconBadgeNumber = 0;
} else {
NSLog(@"PushPlugin skip clear badge");
NSLog(@"[PushPlugin] skip clear badge");
}

if (self.launchNotification) {
Expand All @@ -190,7 +188,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
NSLog( @"NotificationCenter Handle push from foreground" );
NSLog( @"[PushPlugin] NotificationCenter Handle push from foreground" );
// custom code to handle push while app is in the foreground
PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
pushHandler.notificationMessage = notification.request.content.userInfo;
Expand All @@ -210,11 +208,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void(^)(void))completionHandler
{
NSLog(@"Push Plugin didReceiveNotificationResponse: actionIdentifier %@, notification: %@", response.actionIdentifier,
NSLog(@"[PushPlugin] didReceiveNotificationResponse: actionIdentifier %@, notification: %@", response.actionIdentifier,
response.notification.request.content.userInfo);
NSMutableDictionary *userInfo = [response.notification.request.content.userInfo mutableCopy];
[userInfo setObject:response.actionIdentifier forKey:@"actionCallback"];
NSLog(@"Push Plugin userInfo %@", userInfo);
NSLog(@"[PushPlugin] userInfo %@", userInfo);

switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateActive:
Expand All @@ -228,7 +226,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
}
case UIApplicationStateInactive:
{
NSLog(@"coldstart");
NSLog(@"[PushPlugin] coldstart");

if([response.actionIdentifier rangeOfString:@"UNNotificationDefaultActionIdentifier"].location == NSNotFound) {
self.launchNotification = userInfo;
Expand Down Expand Up @@ -256,10 +254,10 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center

id notId = [userInfo objectForKey:@"notId"];
if (notId != nil) {
NSLog(@"Push Plugin notId %@", notId);
NSLog(@"[PushPlugin] notId %@", notId);
[pushHandler.handlerObj setObject:safeHandler forKey:notId];
} else {
NSLog(@"Push Plugin notId handler");
NSLog(@"[PushPlugin] notId handler");
[pushHandler.handlerObj setObject:safeHandler forKey:@"handler"];
}

Expand Down
Loading

0 comments on commit 567552a

Please sign in to comment.