繁体   English   中英

如果应用程序从后台清除,如何处理本地通知

[英]How to handle local notification if the app is cleared from background

我刚刚创建了一个应用程序以在特定时间通知任务,并且它按时完美运行。 如果我单击通知栏,它将打开应用程序并显示一个警告框。

但是当我从后台清除应用程序时遇到了问题。 通知正在运行,但是通过通知打开应用程序时,我看不到警报框。

如果有人知道请帮忙

尝试这个:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

    if(userInfo)
    {

        [self application:application didReceiveRemoteNotification:userInfo];


    }

    return YES;
}
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
}

迅速

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        if let lanuchOptions = launchOptions,
            let userInfo = lanuchOptions[UIApplicationLaunchOptionsKey.remoteNotification] as? [AnyHashable: Any] {

            self.application(application, didReceiveRemoteNotification: userInfo)
        }

        return true
    }

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM