2017-05-29 1 views
-1

iOSのPhonegapアプリケーションを開発しており、プッシュ通知を有効にしたいと考えています。私はGCMを使用し、notifictaion googleを送信すると私の成功は返ってきますが、IOSデバイスは何も表示しません。Phonegap、IOS、デバイスがnotifictaionを受信しない

"android": { 
      "senderID": "xxxxxxxx", "icon": "icon", "badge": "true", "iconColor": "white", "sound": "true", "soundname": "nb" 
     }, 

     "ios": { 

      "senderID": "xxxxxxxx", 

      "alert": "true", 
      "badge": "true", 
      "sound": "true", 
      "usesGCM":true, 
      "sandbox":false, 

      }, 

     "windows": {} 

は私のコードがあります。

+0

あなたの例は完全ではないようです –

答えて

0

まず、プッシュ通知のプラグインをインストールします。

phonegap plugin add phonegap-plugin-push 

のために以下のようにJavaスクリプトコードを書くのiOSが

var note = new apn.Notification(); 
      note.badge = 1; 
      note.sound = "beep.wav"; //path to your sound 
      note.contentAvailable = 1; 
      note.alert = { "body" : msg, "action-loc-key" : "Show Me!" , "launch-image" : "mysplash.png"}; 
      //note.payload = {'uuid': data.uuid}; // additional payload 
      note.device = data.deviceId; 

      var callback = function(errorNum, notification){ 
       console.log('Error is: %s', errorNum); 
       //console.log("Note " + JSON.stringify(notification)); 
      } 
      var options = { 
       gateway: 'gateway.sandbox.push.apple.com', 
       errorCallback: callback, 
       cert: 'test.pem', 
       key: 'test.pem', // ** NEED TO SET TO YOURS 
       passphrase: '', // ** NEED TO SET TO YOURS 
       //port: 2195,      
       enhanced: true,     
       cacheLength: 100     
      } 

      var apnProvider = new apn.Provider(options);  

      apnProvider.send(note, myDevice).then((result) => {   
       console.log("Result :: ",JSON.stringify(result)); 
      }); 

を押した後、それはなります作品。

+0

IOS通知ゲートウェイにgcmを使用します:「gateway.sandbox.push.apple.com」はgcmに適していますか? –

+0

GCMはAndroid用のGoogle Cloud Messagingを意味します。 – Hiten

+0

いいえ、Google Cloud MessagingもIOS向けです。 –

関連する問題