首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >后台的本地通知ios 11

后台的本地通知ios 11
EN

Stack Overflow用户
提问于 2017-09-24 06:03:10
回答 1查看 1.9K关注 0票数 2

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

例如,在我的手机上,我看到了所有的通知-在前景和背景。

在另一部手机上,我只在前台看到通知(在应用程序中),而不是在后台。

是iOS 11的错误吗?

更新-解决

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

EN

回答 1

Stack Overflow用户

发布于 2017-09-27 09:27:49

IOS 11尝试使用这个in - (void)applicationDidEnterBackground:(UIApplication *)应用程序

代码语言:javascript
复制
[self performSelectorInBackground:@selector(showNotical:) withObject:@"Open InBack"];

用方法

代码语言:javascript
复制
- (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];

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46387100

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档