这是我的AppDelegate类。在我的应用程序中,我使用的是Apple推送通知服务。我正在收到推送通知。
但问题是当我点击推送通知提醒中的“查看”按钮时,我的应用程序没有加载。
在任何情况下,我只想在用户点击推送通知提醒的“查看”按钮时显示/加载我的应用程序。
我的代码中的错误是什么,还有我要编写的代码。请帮帮我。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CGRect frame = [UIScreen mainScreen].bounds;
window = [[UIWindow alloc] initWithFrame:frame];
window.backgroundColor = [UIColor blackColor];
[window makeKeyAndVisible];
splashScreen = [[SplashViewController alloc] initWithImage:[UIImage imageNamed:@"Screen.png"]];
navigationController = [[UINavigationController alloc] initWithRootViewController:splashScreen];
[window addSubview:navigationController.view];
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication]registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert |UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
return YES;
}
- (void)application:(UIApplication *)app
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *str =
[NSString stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(@"%@", str);
}
- (void)application:(UIApplication *)app
didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"%@", str);
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}