Pergunta

I want to send the device token to server in my application. I am using following method to retrieve the device token.

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
     NSLog(@"deviceToken: %@", deviceToken);
}

but not worked in ios6. How can do this?

Foi útil?

Solução

Have you written this line

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
 (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

inside this function,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

It should work in iOS 6 if you have done this.

Outras dicas

If you are using Urbanariship you need to clean up the deviceToken before sending it back via a NSURLConnection PUT to the urbanairship servers.

NSString *deviceToken = [[_deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""];
    deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @">" withString: @""] ;
    deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @" " withString: @""];

Other wise you can send using NSURequest/ NSURLConnection

Hope this will help you out. or just let us know if you want code for Request and Connection as well.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top