推送通知未收到(phonegap-push-plugin,ios,GCM)

时间:2016-06-06 18:04:15

标签: ios cordova google-cloud-messaging phonegap-plugins

我试图从icm上的gcm中恢复推送。

我在那里注册了我的申请:https://developers.google.com/mobile/add?platform=ios&cntapi=gcm&cnturl=https:%2F%2Fdevelopers.google.com%2Fcloud-messaging%2Fios%2Fclient&cntlbl=Continue%20Adding%20GCM%20Support&%3Fconfigured%3Dtrue

上传了p12证书,将获得的GoogleService-Info.plist添加到ios xcode项目的根目录。

var params = {
      "android": {"senderID": APP.senderId},
      "ios": {"alert": "true", "badge": "true", "sound": "true", "senderID": APP.senderId},
      "windows": {}
    };
var push = PushNotification.init(params);
push.on('registration', function(data) {
   console.log(data);
   ...
});

push.on('notification', function(data) {
   console.log(data);
   ...
});
push.on('error', function(data) {
   console.log(data);
});

注册成功。

然后我尝试从我的服务器发送推送通知:

public boolean send(String recipient, PushNotification notification) {
        LOG.info("sending message :" + recipient);
        Message message = new Message.Builder()
                .addData("title", notification.getTitle())
                .addData("message", notification.getMessage()) 
                .priority(Message.Priority.HIGH)
                .build();
        try {
            Result result = sender.send(message, recipient, RETRIES_COUNT);
            LOG.debug("result : " + result);
            if (result.getSuccess() != null && result.getSuccess() > 0) {
                return true;
            }
            if (result.getFailure() != null) {
                LOG.error("Error: " + result.getErrorCodeName());
            }
            return false;
        } catch (Exception e) {
            LOG.error(e);
            return false;
        }
    }
}

我在日志中得到以下内容:

16-06-06 20:28:32,868 INFO : [pool-2-thread-1] sending message :k3YUHDkEaR0:APA91bGSc9Wc3dvrS1-6EKBPL4Duu_xZDIujiUZjhkxaaHz3BS3n_ZciuQZLfFiEszXAX4kNUu7Oq0555jI3zzrgIVeNKtD0p63ftH6BPuhOXkCk-ujHlBTi9gSPRXJ6ixd_kTyCfrwS
16-06-06 20:28:33,246 DEBUG: [pool-2-thread-1] result : [ messageId=0:1465234217220513%ca70b4fbf9fd7ecd ]

但是在电话里我什么都没得到。我做错了什么?

0 个答案:

没有答案