1

我的版本的Xcode 6.3.2是..我'建立一个离子的应用,并已在我的科尔多瓦 - iOS 4.1的安装的PhoneGap-插件推1.8.4 0.1 ...push插件科尔多瓦IOS GCM不触发注册事件/不显示设备令牌

我的代码工作完全在Android,但在iOS我'无法注册装置凭证也没有我在Xcode控制台中看到任何错误。我按照所有的步骤并安装开发推送通知证书和启用以及

在Xcode中一般部分有选择的球队..下面是我的代码

angular.module('starter', ['ionic', 'starter.controllers','ngCordova']) 

.run(function($ionicPlatform,$cordovaVibration,$state,$ionicPopup) { 
    $ionicPlatform.ready(function() { 
     var push = PushNotification.init({ 

    ios: { 
     senderID: "XXXXXXXXXXX", 
     alert: "true", 
     badge: "true", 
     sound: "true", 
     gcmSandbox: "true" 
    }, 

}); 

push.on('registration', function(data) { 
    alert(data.registrationId); 
    window.localStorage['gcm_token'] = data.registrationId; 
}); 

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

push.on('error', function(e) { 
    window.localStorage['gcm_tokenn'] = e.message; 
}); 

}) 
}) 

我在想什么?有在Xcode中没有错误日志已三重检查这个..我已经添加在FCM中.P12证书......而且在实际设备上测试了这个,而不是模拟器

+0

您可以检查此相关的[GitHub上的问题(https://github.com/phonegap/phonegap-plugin-push/issues/567)的建议,如果你建立你的应用程序作为开发,那么你需要设置'gcmSandbox:TRUE' 。如果你为生产建立你的应用程序,那么你需要设置'gcmSandbox:false'。我已经看到您已尝试过可能的解决方法,但仍遇到错误。我查了这些论坛:[点击这里](https://forums.developer.apple.com/thread/46011)和[这里](https://github.com/phonegap/phonegap-plugin-push/issues/842 ),而且这似乎是Apple APN之前的一个问题。 – abielita

回答

1

下能力这是我得到了它的工作..安装操作系统MacOS的::塞拉利昂10.12.3的Xcode 8.2.1的PhoneGap-插件推后1.8.4 ..我做到了,

cordova platforms --save 
cordova plugins --save 
rm -rf platforms 
rm -rf plugins 
ionic state restore 

现在我得到令牌,但有其他的问题,而我第一次运行该应用程序,我得到一个错误说

the operation couldnt be completed com.google.iid error 6 

发生这种情况在第一时间..而whi勒我试图用我的PHP代码发送通知我得到后第一时间和NotRegistered成功..

下面是PHP代码我使用

<?php 

$apiKey = "XXXXXXXXXXXXXXXXXXXXX"; 
$regId = 'kK4tkHyseLc:APA91bE6pozxxJC2_MZZtFC38mL5A3PRAaCekT1RLwGJcJZOHtsqtbxUZ56j-ZotoxRlCR8gEKqYbxqOQd37uSs38nJGZAZW7Nb4J6K7HuR5c46FIu05w8qsHUWlGvcQfl8fn-pY__Al'; 
    $url = 'https://gcm-http.googleapis.com/gcm/send'; 
    $post = '{"to" : "' . $regId . '","priority":"high","content_available":true,"time_to_live":2419200,"data":{"message":"GCM Notifier:Message Success","title":"GCM Notifier:Title Success"},"notification":{"title":"GCM Notifier:Title Success","body":"GCM Notifier:Message Success","sound":"default","badge":"1"}}'; 

    $headers = array(
      "Authorization:key=$apiKey", 
      'Content-Type:application/json' 
      ); 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

$result = curl_exec($ch); 
if (curl_errno($ch)) 
{ 
    echo 'GCM error: ' . curl_error($ch); 
} 
curl_close($ch); 
    echo $result; 
?> 

响应::

{"multicast_id":8300626558747339726,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]} 
0

我有同样的问题早。通过更新Xcode到最新版本(Xcode 8)解决了我的问题。要在应用程序中成功整合phonegap-plugin-push插件1.8.4,需要Xcode版本8 for iOS。

也不要忘记启用推送通知在Xcode

+0

我会试试这个..目前Xcode 6.3.2没有在功能下推送通知的选项。我会更新我的xcode和回复,.. – Aniket

+0

是的。你必须将Xcode版本更新到8,这将有助于解决你的问题。 –

+0

您是否能够将您的Xcode版本更新至8并且能够解决您的问题? –