本文介绍了如何在目标c中的didFinishLaunchingWithOption应用程序方法中检测远程通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当应用程序不处于后台模式,处于非活动模式且应用程序已完全关闭时.而不是如何使用应用程序的委托"didFinishLaunchingWithOption"方法来检测其任何通知.我已经搜索了很多关于它,但一无所获.请帮忙.
when app in not in background mode ,inactive mode and app is completely closed. than how to detect is their any notification using application's delegate "didFinishLaunchingWithOption" method. i have searched a lot about it but not get anything. please help .
谢谢
推荐答案
以下方法用于通知
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
}
}
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *token = [[[[deviceToken description]
stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"Token:%@",token);
}
//app is forground this method will access
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
}
//need to on teh background fetch option in info plist
//app is background state this below mthod will call while notification receives
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"Background mode working%@",userInfo);
if([userInfo[@"aps"][@"content-available"] intValue]== 1) //it's the silent notification when recive preferences and text messages
{
}
}
//handling interactive notification
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forLocalNotification:(nonnull UILocalNotification *)notification completionHandler:(nonnull void (^)())completionHandler {
}
这篇关于如何在目标c中的didFinishLaunchingWithOption应用程序方法中检测远程通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!