简体   繁体   English

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

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

I just created an application to notify the task in a specific time.And It's working perfectly on time. 我刚刚创建了一个应用程序以在特定时间通知任务,并且它按时完美运行。 If I click on the notification bar it opens the app and show a alert box. 如果我单击通知栏,它将打开应用程序并显示一个警告框。

But I have problem when i cleared the application from background. 但是当我从后台清除应用程序时遇到了问题。 Notification is working but I can't able to see the alert box when the application is opens through notification. 通知正在运行,但是通过通知打开应用程序时,我看不到警报框。

Please help if any one know 如果有人知道请帮忙

try this: 尝试这个:

- (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
{
}

swift 迅速

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.

相关问题 当应用程序在后台时处理本地通知 - Handle local notification when app is in background 在后台处理本地通知并暂停 - Handle local notification in background and suspended 如何在应用程序处于后台时处理 iOS 远程通知 - How to handle iOS remote notification while app is in background 如何在应用程序处于后台但未暂停时处理推送通知 - How to handle push notification when app is in background but not suspended 如何在不使用本地通知的情况下将IOS应用程序从后台导入前台? - How to bring IOS app from background to foreground without using local notification? 我如何知道该应用在后台被杀死后是否已从本地通知中打开? - How can I know if the app has been opened from a local notification after it has been killed in the background? 如何知道在应用程序处于后台时是否触发了本地通知? - How to know if a local notification was fired while the app is in background? 如何在点击本地通知时确定后台应用程序成为前台 - How to determine background app come to foreground in action of tapping local notification 如何在后台处理NSLocal Notification? - how to handle NSLocal Notification in background? 从iOS通知面板激活应用程序时,是否可以处理所选的本地通知? - Is it possible to handle the selected local notification when activing the app from iOS notification panel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM