热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

本地通知ios11在后台-localnotificationsios11inbackground

IpreparediOSappincordova,IusedoriginalCordovaPluginforLocalNotifications.Imschedulin

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.

我在cordova中准备了iOS应用程序,我使用原始Cordova插件进行本地通知。我在通知中心安排了大约90个本地通知。它在iOS 10上运行,但在iOS 11上并不总是在每台设备上都有。

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?

这是iOS 11的错误吗?

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.

用于本地通知的Cordova插件只能安排64个本地通知(如iOS文档限制)。因此,我需要使用队列为64个当前本地通知和数据库编写本机模块,以便在限制之后设置下一个本地通知。

1 个解决方案

#1


0  

IOS 11 try use this in - (void)applicationDidEnterBackground:(UIApplication *)application

IOS 11尝试在 - (void)applicationDidEnterBackground:(UIApplication *)应用程序中使用它

[self performSelectorInBackground:@selector(showNotical:) withObject:@"Open InBack"];

with method

- (void) showNotical:(NSString*)msg 
{ 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]; }

推荐阅读
author-avatar
D之phper
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有