15
Requirements for Push Notification Android GCM Details Sender ID(Project ID) API KEY(Application ID) Registration ID Browser API Key References for Configuring GCM: http://androidexample.com/ Android_Push_Notifications_using_Google_Cloud_Messaging_GCM/index.php? view=article_discription&aid=119&aaid=139 http://www.tejaprakash.com/2013/02/google-cloud-messaging-for- android.html http://rdcworld-android.blogspot.in/2013/11/android-push-notification- google-cloud.html References for .net app to send notification through GCM server to phone http://www.tejaprakash.com/2013/05/push-messages-to-gcm-server-using- net.html References for .net app to send notification to both android and IOS http://www.codeproject.com/Questions/679751/Push-Notification-for- Android-and-iPhone-in-ASP-NE Apple IPhone APNS Details An application ID which is used to uniquely identify your application to Apple's services Device Token certificate file (.cer) and Personal Information Exchange (.pem/.p12) Device Token of length 64. Next is the password that was created at the time the certificate was generated using the Apple MAC OS is also required.

Requirements of Push Notification

Embed Size (px)

DESCRIPTION

Push notification details

Citation preview

Page 1: Requirements of Push Notification

Requirements for Push Notification

Android GCM Details Sender ID(Project ID) API KEY(Application ID) Registration ID Browser API Key

References for Configuring GCM:http://androidexample.com/Android_Push_Notifications_using_Google_Cloud_Messaging_GCM/index.php?view=article_discription&aid=119&aaid=139

http://www.tejaprakash.com/2013/02/google-cloud-messaging-for-android.html

http://rdcworld-android.blogspot.in/2013/11/android-push-notification-google-cloud.html

References for .net app to send notification through GCM server to phone

http://www.tejaprakash.com/2013/05/push-messages-to-gcm-server-using-net.html

References for .net app to send notification to both android and IOS

http://www.codeproject.com/Questions/679751/Push-Notification-for-Android-and-iPhone-in-ASP-NE

Apple IPhone APNS Details

An application ID which is used to uniquely identify your application to Apple's services Device Token certificate file (.cer) and Personal Information Exchange (.pem/.p12) Device Token of length 64. Next  is the password that was created at the time the

certificate was generated using the Apple MAC OS is also required.

Procedure to use those certificates in Windows OS Get or generate the certificate file (.cer) and Personal Information Exchange (.pem/.p12) file from the Apple Mac OS. Convert the .pem to a .pfx file because the ASP.Net Web API works with the .pfx file using SSLConverter. To convert the file go to https://ssl4less.eu/ssl-tools/convert-certificate.html#certificateConverter

In this article, I would like to explain Apple Push Notification using ASP.Net. Push Notification is widely used in the iPhone development.

Page 2: Requirements of Push Notification

1. Get or generate the certificate file (.cer) and Personal Information Exchange (.pem/.p12) file from the Apple Mac OS.

2. Convert the .pem to a .pfx file because the ASP.Net Web API works with the .pfx file using SSLConverter.

3. To convert the file go to https://ssl4less.eu/ssl-tools/convert-certificate.html#certificateConverter

4. Now you have 2 files, in other words a certificate file (.cer) and a .pfx file. Install both files using Microsoft Management Console (MMC).

5. Type mmc after pressing <Windows> + R.

Page 3: Requirements of Push Notification

 6. Press "OK" and a new screen will open.

 7. Install the certificate (aps_development.cer ) and Personal Information Exchange files

(.pfx, .p12) into the Personal-Certificates folder.

Page 4: Requirements of Push Notification

 8. After selecting "Import", it will ask where you need to install the certificate. Select the

"Computer" account.

Page 5: Requirements of Push Notification

 9. Select "Local computer" -> "Finish-Certificates". Click on "Add" and then "Ok".

Page 6: Requirements of Push Notification

 10. Click "Browse" -> "Next" -> "Next" -> "By default selected". Place all certificates in

the following store:

Page 7: Requirements of Push Notification
Page 8: Requirements of Push Notification
Page 9: Requirements of Push Notification
Page 10: Requirements of Push Notification
Page 11: Requirements of Push Notification

11. Click on "Finish" and the certificate file is successfully imported into the Personal-Certificates folder.

Page 12: Requirements of Push Notification

Repeat the same process to install the .pfx file into the Personal-Certificate folder.

Also install both the files (.cer and .pfx) into the "Trusted Root Certification Authorities -Certificate" folder.

Page 13: Requirements of Push Notification

This environment is ready to send Push Notification.

The following is the ASP.Net method to send Push Notification using ASP.Net via Apple.

Download the file Project.zip. Extract and add it your project. Build Project.MoonAPNS. Add a reference in your web application/web API. A simple class file for PushNotificationToApple is as follows.

using Project.MoonAPNS;using System.Net.Security;using System.Net.Sockets;using System.Security.Cryptography.X509Certificates; public Int64 PushNotificationToApple(Messages messageObject){            Int64 result = 0;            Messages message = null;            try            {                string strDeviceToken ="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";                string strPushMessage = "Good Morning!";                var payload1 = new NotificationPayload(strDeviceToken, strPushMessage, 1,"default");                payload1.AddCustom("RegionID", "IDQ10150");                 var p = new List<NotificationPayload> { payload1 };                string certificatePath = HttpContext.Current.Server.MapPath("/debug/ck.pfx");                var push = new PushNotification(true, certificatePath, "XXXXXX");                string strfilename = push.P12File;                var message1 = push.SendToApple(p);                foreach (var item in message1)                {                    result = 1;                }            }            catch (Exception ex)            {            }       return result;}

Page 14: Requirements of Push Notification

In the preceding class, strDeviceToken is a DeviceToken of length 64. Next XXXXXX is the password that was created at the time the certificate was generated using the Apple MAC OS.

To Generate a Certificate in MAC OS First to Register the app and later follow other steps