0

Я работаю Cordova iOS Платформа. Мне нужно добавить Push Notification в моем проекте.iOS PushPlugin Cordova выпуск в регистрации

Шаги:

  1. Я создал проект в консоли Google и создал Project-ID.

  2. Создал сертификат производителя APNS PushNotification от Apple Developer.

  3. Ниже Plugin Добавлено в моем проекте

    cordova plugin add phonegap-plugin-push --variable SENDER_ID="722784892462"

В index.js

var pushNotification; 
gcmNotification = { 
    onNotificationAPN : function (e) { 
     if (e.id) 
     { 
     navigator.notification.beep(); 

     } 
    }, 
    registerPushNotification : function() { 
    try{ 
     pushNotification = window.plugins.pushNotification;  

     var errorHandler = function (error) { 
     console.log(error); 
     }; 

     var tokenHandler = function (result) { 
      alert('device token = ' + result); 
     }; 

     pushNotification.register(tokenHandler, errorHandler, { "badge": "true", "sound": "true", "alert": "true", "ecb": "onNotificationAPN" }); 

    }catch(e){ 
     exceptionAlert("registerPushNotification>>"+e); 
    } 
    } 
} 

function onNotificationAPN(e) 
{ 
    gcmNotification.onNotificationAPN(e); 
} 

Я пытался в моем реального устройства.

я получил ошибку ниже:

enter image description here

ответ

0

Я ве нашел решение. я заменил код из PushNotification.js к Push.js

https://github.com/phonegap/phonegap-plugin-push/tree/master/www

и добавил следующий код в index.js

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

push.on('registration', function(data) { 
    // data.registrationId 
}); 

push.on('notification', function(data) { 
    // data.message, 
    // data.title, 
    // data.count, 
    // data.sound, 
    // data.image, 
    // data.additionalData 
}); 

push.on('error', function(e) { 
    // e.message 
}); 
0

ли у добавить cordova.js файл в HTML-страницу

<script type="text/javascript" src="cordova.js"></script> 
+0

cordova.js уже добавлены. Мои другие плагины работают отлично, за исключением этого – GaneshKumar

+0

Я попробовал, чтобы это работало для меня. проверьте этот URL https://github.com/phonegap-build/PushPlugin –