我正在使用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