Configuring Push Notifications For Xamarin Forms

By: Admin

Push Notifications are one-way forms of communication offered to mobile users that some operation (like an update, deletion, or addition) has happened.

configuring push notifications - alligatortek

To send a push notification to an Apple device, use the Apple Push Services. For an Android device, use Google’s Firebase Cloud Messaging Services. Fortunately, if you’re sending a push notification to an app on both platforms, Microsoft offers an easier way through  Microsoft Azure Notification Hub.

Go to the Azure portal.

  1. Click “Create a resource”, “Web + Mobile” and select “Notification Hub.”notification hub
  2. In the new window, enter the notification hub name and create a new namespace.
  3. Select a location. We recommend a location closest to the user or closest to you (the developer).
  4. Choose an existing resource group or create a new resource group.
  5. Select your Microsoft subscription (for billing purposes).
  6. Choose a pricing tier based on your usage needs and click “Select” to close the pricing tab.
  7. Click “Create” to create the new notification hub. It may take few minutes to create and configure.creating notification hub
  8. Choose the “Google (GCM)” from the side menu. This section is used to configure and send Android-based push notifications using Birebase cloud messaging.google GCM option

Create the Firebase Push Notifcation

  1. Open a new browser window and navigate to https://console.firebase.google.com/.
  2. Login or create a new account. After you have logged in, click “+ Add Project”.Adding project
  3. Enter the Project Name and Country/region. You can change the Project ID if required.
  4. Click “CREATE PROJECT.” It may take a few minutes to create the project.
  5. After the message “Your new project is ready”, click “CONTINUE” to navigate to the project page.Project created
  6. In the new page, select “Add Firebase to your Android app” to create an Android-based Firebase app.Add firebase
  7. In the next screen, enter the “Android package name” and enter an optional app nickname. Select “REGISTER APP.Registering app
  8. In the next screen, click “Download google-services.json” and download the file.download json file
  9. Open the downloaded file and copy the project number  (a 12-digit code like 272477558565) into the project’s AppSettings.cs file for FirebaseSenderID.

Create push services for iOS:

  1. Select “Apple (APNS)” from the Azure portal side menu.Azure portal menu
  2. Upload a certificate to send push notifications on iOS. Log in to https://developer.apple.com.
  3. Navigate to “Certificates, Identifiers and Profiles.Navigate to profiles
  4. Select the Apple ID associated with the application.
  5. Ensure that the ID is configured to use Push Notifications. It should have the status as Configurable. Click “Edit” to configure push services.Configure ID
  6. In the next screen, choose to create either a development or production SSL certificate and click “Create Certificate.Choose certificate
  7. The next screen requires you to create a “certSigningRequest”. Create the file and upload it.
    1. On the Mac, open the “Keychain Access” application: press WinKey + Spacebar to open Spotlight. Type “keychain access” and press enter.
    2. Select Keychain Access -> Certificate Assistant -> Request a Certificate From a Certificate Authority.Keychain access
  8. Enter the user email address, command name, and Certificate Authority (CA) Email address.
  9. Select “Saved to disk” and click “Continue”.Save details
  10. In the popup dialog, save the certSigningRequest.
  11. Choose a location. If you’re choosing a default location, make sure to note the location for future purposes.
  12. Now navigate back to the apple developer website and upload the previously created certSigningRequest and select “Continue.Navigate to apple
  13. In the next screen, click “Download” button to download the .cer file. After downloading the file, select “Done” and close the browser.Certificate file
  14. Double click to open the .cer file. It will by default open the Keychain Access application.
  15. Enter the administrator password to install the .cer file.install certificate
  16. Right-click on the certificate and choose “Export [Certificate Name].”Explore the certificateEnter a name for the “.p12” file. Select the location of the file and click “Save.” Make sure the file format is “Personal Information Exchange (.p12)” before saving the file.PIE""
  17. Enter a password for the p12 file. Re-enter the password.Creadentials
  18. Enter the administrator password for Keychain Access application to export the key and select “Allow.”Keychain access application

Now navigate back to the Azure portal.

  1. Select Folder Icon.select folder
  2. Find the p12 file and click “Open.” Enter the same password used to create the file. Save.Creadentials to create
  3. Open the Backend Mobile app service from the Azure portal and navigate to “Push” from the sidebar menu.
  4. Connect to the notification hub we created earlier.connect hub
  5. Choose the previously created notification hub.choose notification hub
  6. On the next screen, add the tag “UserGroup1” for push notifications to be delivered to the mobile devices. Save.select group for notifications

 

 

What are you looking for?

Join our newsletter list of over 5,000 innovators and receive an email update every other month

Copyright © 2018 alligatortek. All rights reserved.