0

Я пытаюсь отправить некоторые данные по лазурной подвижной службе на устройства IOS, основанных на том, что я узнал из этого урока https://github.com/ggailey777/mobile-services-samples/tree/master/CordovaNotificationsArticle,Отправить дополнительное данные толчок уведомления для устройств IOS использования Azure

Однако, когда я установил полезную нагрузку на Лазурный как это

var payload = '{ "message" : "' + message + '", "title" : "Title...", "id" : "' + recordid + '" }'; 

только Android устройство может получить дополнительные данные о событии уведомления Кордовы толчок плагина, но на прошивке, ничего, кроме data.message не определенно.

push.on('notification', function (data) { 
    var recordID = data.additionalData.id 
}); 

И вот мой код для регистрации:

var push = PushNotification.init({ 
     "android": { "senderID": AzureMobileServiceClient.senderID }, 
     "ios": { "alert": true, "badge": true, "sound": true } 
    }); 

    push.on('registration', function (data) { 

      //// Call mobile service client here 
      var mobileServiceClient = new WindowsAzure.MobileServiceClient(AzureMobileServiceClient.API_URL, AzureMobileServiceClient.API_KEY); 

      // Get the native platform of the device. 
      var platform = ""; 
      if (ionic.Platform.isIOS()) { 
       platform = "iOS"; 
      } 
      else { 
       platform = "android"; 
      } 

      var tags = [userid, platform]; 
      // Get the handle returned during registration. 
      var handle = data.registrationId; 
      // Set the device-specific message template. 
      if (platform == "android" || platform == "Android") { 
       // Template registration. 
       var template = '{ "data" : {"message":"$(message)", "id": "$(id)", "title": "$(title)"}}'; 
       // Register for notifications. 
       mobileServiceClient.push.gcm.registerTemplate(handle, 
        "myTemplate", template, null, tags) 
        .done(registrationSuccess, registrationFailure); 
      } else if (platform == "iOS") { 

       // Template registration. 
       var template = '{"aps": {"alert": "$(message)"}}'; 

       // Register for notifications.    
       mobileServiceClient.push.apns.registerTemplate(handle, 
        "myTemplate", template, null, tags) 
        .done(registrationSuccess, registrationFailure); 
      } 

     }); 

Кто-нибудь знает, как получить дополнительные данные о прошивке? Буду признателен за любую оказанную помощь.

Спасибо!

+0

Можете ли вы показать шаблон, который вы используете в регистрации? Для Apple пользовательские данные находятся за пределами узла aps, поэтому шаблон, подобный {"aps": {"alert": "@ {message}", "id": $ {id}} или так. – phillipv

ответ

1

Шаблон для регистрации клиента приложение IOS выглядит следующим образом:

{"aps": {"alert": "$(message)"}} 
Смежные вопросы