What are the steps to implementing Apple Push Notification?

I am new to this topic and require some guidance on implementing Apple Push Notification in my application. I created my appID and also set up Apple Push Notification for the same. I downloaded the preparation profile and installed the application on iphone. I also wrote 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 need to write on the server side. When I run the code, it says that the device is not registered. How to register an application for push notification.

Can anyone help me with this ...

Any code would be very helpful ...

Thanx in advance ...

+7
objective-c iphone apple-push-notifications
source share
2 answers

You need to inform the server about the device token that Apple sent when you register for notifications from the device, so that the server can present the same token and application identifier when it tells the Apple server that there is a new notification. Did you do it? I believe that the device token can change every time you register, so you need to track this on your server (and tell the server each time).

You specified the callbacks associated with registering the device, but did you really call the registration method itself?

+2
source share

You also need to listen to didReceiveRemoteNotification if you want to know when notifications will appear when the application is in the foreground. You can also clear the icon number set on the application icon when the user has read the notification sent to them.

0
source share

All Articles