Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aligned iOS local fg notification behavior with Android (localNotificationReceived only triggers when tapped, not when shown) #3348

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -589,11 +594,6 @@ -(void)application:(UIApplication*)application didChangeStatusBarFrame:(CGRect)o

- (void)application:(UIApplication*)application didReceiveLocalNotification:(UILocalNotification*)notification {
CN1Log(@"Received local notification while running: %@", notification);
javieranton-zz marked this conversation as resolved.
Show resolved Hide resolved
if( [notification.userInfo valueForKey:@"__ios_id__"] != NULL)
{
NSString* alertValue = [notification.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));
}
}

#ifndef CN1_USE_ARC
Expand Down