2015-10-25 103 views
0

我正在开发Xamarin.Forms应用程序,并且在配置推送通知时遇到了一些问题。我遵循https://azure.microsoft.com/en-us/documentation/articles/partner-xamarin-mobile-services-xamarin-forms-get-started-push/上的文档,但这只会教你如何通过推送通知来响应请求。推送通知渠道Azure JS后端

如何创建推送通知并将其发送给Xamarin.Forms中的用户?如何设置不同的推送渠道,以便一次性通知特定用户组?

正因为如此,这里是与推送通知响应我的JavaScript后端代码:

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 }); 
       }   
     });     
     } 
    }); 
    } 
+0

这只是一个建议。值得看看parse.com,它有一个推送通知服务和所有平台的非常简单的API。 –

回答

1

推送通知是棘手的,因为他们需要甚至在每形式不同平台处理。本文通过.net后端完成整个过程,但它应该回答您的问题。

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

你是让用户注册到不同的标签,然后只发送给那些代码发送给不同类型的用户。标签就是你所说的组织。

+0

是否可以向RegistrationId而不是用户发送推送通知?我知道RegistrationIds与用户相关联,但如果我只能使用RegistrationId,那对我来说会更方便。 – Oblivionkey3

+0

感谢您指点我在正确的方向,我发现我需要在这里虽然示例:http://stackoverflow.com/questions/20950514/how-to-send-a-notification-for-a-particular-android-device -by-GCM-贯通窗 – Oblivionkey3