[英]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.