我正在使用PushNotification为我的应用程序。它似乎每次加载应用程序时都会生成设备令牌。所以在我的服务器中,我有许多重复的设备令牌。iPhone PushNotification注册多次
我需要将它添加到数据库之前,检查设备令牌还是我做一些事情错在应用程序执行?
下面是我使用的代码段。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// launchOptions has the incoming notification if we're being launched after the user tapped "view"
NSLog(@"didFinishLaunchingWithOptions:%@", launchOptions);
// [self.viewController handleDidReceiveRemoteNotification:userInfo];
// other setup tasks here....
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
// [self updateWithRemoteData]; // freshen your app!
// RESET THE BADGE COUNT
application.applicationIconBadgeNumber = 0;
// ...
// call the original applicationDidFinishLaunching method to handle the basic view setup tasks
[self applicationDidFinishLaunching:application];
return YES;
}
- (void)application:(UIApplication *)app
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
[self sendDeviceTokenToRemote:devToken]; // send the token to your server
}
有人可以帮忙吗?如何将独特的设备令牌存储在我的服务器中?
感谢, Nikil
感谢yar对我来说非常有用。 – nambi 2012-01-09 10:37:18