我在我的应用程序委托文件中使用了这些方法,并且能够在我的 iphone 上激活通知服务,但我的问题是,因为我想在我想要的时候向我的朋友 iphone 发送警报。为此,我想使用推送通知来自动更新他手机中的闹钟时间和消息。
//in did finishlaunching
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken1 {
NSString *str = [NSString
stringWithFormat:@"Device Token=%@",deviceToken1];
NSLog(@"device......%@",str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"device......%@",str);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}