diff --git a/Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m b/Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m index 4ce4cd9448..19d200403f 100644 --- a/Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m +++ b/Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m @@ -394,8 +394,6 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNot { CN1Log(@"Received local notification while running: %@", notification); - NSString* alertValue = [notification.request.content.userInfo valueForKey:@"__ios_id__"]; - com_codename1_impl_ios_IOSImplementation_localNotificationReceived___java_lang_String(CN1_THREAD_GET_STATE_PASS_ARG fromNSString(CN1_THREAD_GET_STATE_PASS_ARG alertValue)); if (completionHandler != nil) { if ([notification.request.content.userInfo valueForKey:@"foreground"] != NULL) { completionHandler(UNNotificationPresentationOptionAlert); @@ -419,8 +417,15 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNot - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { - - +#ifdef CN1_INCLUDE_NOTIFICATIONS + if( [response.notification.request.content.userInfo valueForKey:@"__ios_id__"] != NULL) + { + CN1Log(@"Tapped on locally initiated notification: %@", response.notification); + NSString* alertValue = [response.notification.request.content.userInfo valueForKey:@"__ios_id__"]; + if ([response.notification.request.content.userInfo valueForKey:@"foreground"] != NULL) + com_codename1_impl_ios_IOSImplementation_localNotificationReceived___java_lang_String(CN1_THREAD_GET_STATE_PASS_ARG fromNSString(CN1_THREAD_GET_STATE_PASS_ARG alertValue)); + } +#endif #ifdef INCLUDE_CN1_PUSH NSLog( @"Handle push from background or closed" ); // if you set a member variable in didReceiveRemoteNotification, you will know if this is from closed or background