更新时间:2023-02-26 22:23:07
尝试处理这个点击代码,
Try to handle this the click as shown in code,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Accept push notification when the app is not open.
if (remoteNotifiInfo) {
[self application:application didReceiveRemoteNotification: remoteNotifiInfo];
}
}
// On click of notification open related screen.
像这样覆盖 didReceiveRemoteNotification
override didReceiveRemoteNotification like this
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if ( state == UIApplicationStateInactive )
{
//Your actions on notification click
double delayInSeconds = 0.3;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//code to be executed on the main queue after delay
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushTOEventDetails" object:eventVO];
});
}
}