views:

205

answers:

1

Hi everybody,

I am new to this topic and require some guidance in implementing Apple Push Notification in my application. I have created my appID and also configured Apple Push Notification for the same. I have downloaded the provisioning profile and installed the app on the iphone. I have also written the following code provided by Apple documentation

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
const void *devTokenBytes = [devToken bytes];
NSLog(@"devToken=%@",devTokenBytes);
//self.registered = YES;
//[self sendProviderDeviceToken:devTokenBytes]; // custom method
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err);
}

I want to know what I have to write on the server side. When I run the code it says that the device is not registered. How can I register my application for the push notification.

Can anyone help me with this...

Any code will be very helpful...

Thanx in advance...

+1  A: 

You need to tell your server about the device token returned by Apple when you register for notifications from the device, so that the server can present the same token and app id when it tells the apple server that there's a new notification. Have you done that? I believe the device token could change each time you register, so you'll need to keep track of that on your server (and tell the server each time).

You've shown the callbacks involved in device registration, but have you actually called the registration method itself?

Jon Skeet
yes I have called the registration method but msg in console says registration error and the error no is 3000. Can you help me with this.
Atulkumar V. Jain
Well if registration failed then I'm not surprised that your server can't notify the device. I'm on a phone right now, but I suggest you look up error 3000 in the documentation.
Jon Skeet