Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the steps in implementing Apple Push Notification?

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...

like image 693
Atulkumar V. Jain Avatar asked Jan 23 '10 08:01

Atulkumar V. Jain


People also ask

How do I set up Apple push notifications?

Setting up Push Notifications in iOS. Go back to the iOS project you created earlier and select the main target. Under the Signing & Capabilities tab, click on the + Capability button, then select Push Notifications. This will enable your app to receive push notifications from OneSignal.

Does Apple send push notifications?

Remote Notifications Communicate with Apple Push Notification service (APNs) and receive a unique device token that identifies your app. Use basic macOS command-line tools to send push notifications to Apple Push Notification service (APNs).

How many types of push notification are there in iOS?

Here are four types of push notifications, including mobile, to test in your next campaign. 1. Mobile app push notifications: generated via an app downloaded on a user's mobile device. Displayed in three locations: lock screen, banner and notification center.


1 Answers

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?

like image 117
Jon Skeet Avatar answered Oct 26 '22 13:10

Jon Skeet