views:

543

answers:

1

Hi,

In my application i am going to use pushNotification. So in that case how can i use device tokens in different ways?

Let me elaborate more on this side.

Whenever i run my application at that time Device token will be generated,if i go for running the application again and again in the same device than it will generate the same device token or not?

if it will generate the different Device tokens than as per the Apple Documentation how is it Handling at the server side.? what is exactly needed to send from client side (i.e. Device token or other parameters) to the server side and which type of scenario is having at the server side for the same?

if anybody having any solution or any code snippet or any useful link,which would be appreciated.

Thanks,

Mishal Shah.

+2  A: 

Here is an example, not necessarily working code:

- (void)sendProviderDeviceToken:(NSString *)tokenString {
    NSString *udid = [[UIDevice currentDevice] uniqueIdentifier];

    NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
    UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

    NSString *data = [NSString stringWithFormat:@"udid=%@&token=%@&id=%@&type=%i", udid, tokenString, bundleID, type];
    NSString *escapedData = [[data description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSString *httpRequestURLString = [NSString stringWithFormat:@"http://%@/RegisterDevice.cgi?%@", kRegistrationURI, escapedData];
    NSURL    *httpRequestURL       = [NSURL URLWithString:httpRequestURLString];
}
zaph
Thanks for answer.Really it helped me.Can you please give me any other information about Device Token.I mean whenever i launch my application at that time it will generate the different tokens for that device or not?And if it generates the different tokens than how to handle it in the proper way?Thanks,Mishal Shah
Mishal
Why do you not up vote or accept any answers?
zaph