我想区分app appAsctive是否响应RemoteNotification点击。怎么做 ?
答案 0 :(得分:0)
你可以像这样检查
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (notification) {
// it's launch from notification
}
else
{
// normal launch on app icon click
}
}
对于swift plz使用此
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if (launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? NSDictionary) != nil {
// it's launch from notification
}
else
{
// normal launch on app icon click
}
// Override point for customization after application launch.
return true
}