Reputation: 21
I prepared iOS app in cordova, I used original Cordova Plugin for Local Notifications. I'm scheduling about 90 local notifications in notification center. It's working on iOS 10, but on iOS 11 not always and on not every device.
For example on my phone I see all notifications - in foreground and background.
On other phone I see notifications only in foreground (inside app), not in background.
Is it an iOS 11 bug?
UPDATE - SOLVED
Cordova Plugin for local notifications can only schedule 64 local notifications (like iOS docs limit). So I need to code native module with queue for 64 current local notifications and database to set next local notifications after limit.
Upvotes: 2
Views: 1906
Reputation: 944
IOS 11 try use this in - (void)applicationDidEnterBackground:(UIApplication *)application
[self performSelectorInBackground:@selector(showNotical:) withObject:@"Open InBack"];
with method
- (void) showNotical:(NSString*)msg <br>
{
UIApplication *application = [UIApplication sharedApplication];
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
//UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil];
[application registerUserNotificationSettings:settings];
}
else // iOS 7 or earlier
{
//UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
// localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];
localNotification.alertAction = @"test";
localNotification.alertBody = [NSString stringWithFormat:@"%@",msg];
localNotification.soundName = UILocalNotificationDefaultSoundName; // den den den
localNotification.repeatInterval = 7;
//[UIApplication sharedApplication].applicationIconBadgeNumber=1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
Upvotes: 0