0
votes

I'm developing a Xamarin.Forms app right now and am having some trouble configuring push notifications. I have followed the docs on https://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-xamarin-forms-get-started-push/, but this only teaches you how to respond to a request with a push notification.

How can I create a push notification and send it to a user in Xamarin.Forms? How can I set up different push channels so that specific groups of users are notified at a single time?

As it is, here is my Javascript backend code for responding with push notifications:

  function insert(item, user, request) {
  // Execute the request and send notifications.
     request.execute({
     success: function() {                      
      // Create a template-based payload.
      var payload = '{ "message" : "New item added: ' + item.text + '" }';            

      // Write the default response and send a notification
      // to all platforms.            
      push.send(null, payload, {               
          success: function(pushResponse){
          console.log("Sent push:", pushResponse);
          // Send the default response.
          request.respond();
          },              
          error: function (pushResponse) {
              console.log("Error Sending push:", pushResponse);
               // Send the an error response.
              request.respond(500, { error: pushResponse });
              }           
       });                 
      }
   });   
  }
1
This is just a suggestion. It is worth to take a look at parse.com that has a push notification service and very simple APIs for all platforms.a.toraby

1 Answers

1
votes

Push notifications are tricky because they need different handling per platform even on forms. This article goes through the whole process with a .net back end but it should answer your questions.

http://www.xamarinhelp.com/push-notifications/

You send to different types of users by getting them to register to different tags, then sending only to those tags. Tags are what you would call groups.