iOS 发布后未收到 PN。在开发中工作正常

Not receiving PN in iOS release. works fine in development

我正在尝试集成 phonegap-plugin-push,但似乎无法在发布模式下运行。 将应用程序部署到 TestFlight 或商店时无法接收推送通知。在开发模式下,通知似乎工作正常。

我按照此处定义的步骤安装推送插件:https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md

平台和版本

iOS 11.2.6

Cordova CLI 版本

cordova --version
    8.0.0

Cordova平台版本

Installed platforms:
    android 7.1.0
    ios 4.5.4

cordova 插件版本 | grep phonegap-plugin-push # 例如1.5.3 phonegap-plugin-push 2.2.2 "PushPlugin"

示例推送数据负载

发送任何负载均无效。我尝试从 Firebase 控制台发送 PN 以及 pushtry.com

重现问题时记录的日志

这些是我使用 https://www.npmjs.com/package/cordova-plugin-native-logs

从已部署版本收集的日志

Push.init 在用户登录后调用。

首次登录尝试 - 应用刚刚安装

2018-04-02 14:01:43.976 [432:123186] [CDVTimer][nativelogs] 0.962973ms
2018-04-02 14:01:43.979 [432:123186] [CDVTimer][TotalPluginStartup] 45.592070ms
2018-04-02 14:01:43.988 [432:123186] createNotificationChecker
2018-04-02 14:01:43.988 [432:123186] coldstart
2018-04-02 14:01:44.463 [432:123186] active
2018-04-02 14:01:44.464 [432:123186] PushPlugin skip clear badge
2018-04-02 14:01:45.353 [432:123186] Ionic Native: deviceready event fired after 296 ms
2018-04-02 14:01:46.926 [432:123186] CDVWKWebViewEngine: handleStopScroll
2018-04-02 14:01:48.191 [432:123186] {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":400,"statusText":"Bad Request","url":"1.0/user-details","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://api.example.com/1.0/user-details: 400 Bad Request","error":{"error":"token_not_provided"}}
2018-04-02 14:02:09.478 [432:123186] -[UIWindow endDisablingInterfaceAutorotationAnimated:] called on <UIRemoteKeyboardWindow: 0x1058ae600; frame = (0 0; 414 736); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x1c4035800>> without matching -beginDisablingInterfaceAutorotation. Ignoring.
2018-04-02 14:02:17.532 [432:123186] CDVWKWebViewEngine: handleStopScroll
2018-04-02 14:02:18.754 [432:123186] this.pages is called
2018-04-02 14:02:18.754 [432:123186] register push called
2018-04-02 14:02:18.763 [432:123186] Push Plugin VoIP missing or false
2018-04-02 14:02:18.764 [432:123216] Push Plugin register called
2018-04-02 14:02:18.764 [432:123216] PushPlugin.register: setting badge to false
2018-04-02 14:02:18.764 [432:123216] PushPlugin.register: clear badge is set to 0
2018-04-02 14:02:18.764 [432:123216] PushPlugin.register: better button setup
2018-04-02 14:02:18.767 [432:123216] FCM Sender ID 16--752--616
2018-04-02 14:02:18.767 [432:123216] Using FCM Notification
2018-04-02 14:02:18.902 [432:123186] FCM token is null
2018-04-02 14:02:18.907 [432:123186] Push Plugin register failed
2018-04-02 14:02:19.266 [432:123186] updating address
2018-04-02 14:02:20.084 [432:123186] active
2018-04-02 14:02:20.084 [432:123186] PushPlugin skip clear badge
2018-04-02 14:02:20.691 [432:123186] The FCM registration token needs to be changed.
2018-04-02 14:02:20.699 [432:123186] FCM Registration Token: cuB6DZDZMxs:APA91bHjReRv-TrwFHxsbVVAj5xeHCh56VhVEDtQ2pcLwWUrcttsA8AkOri-M3TBxXPbnkO9VsFSr1Iqzs6oOYHowx8NlEW4N3MflU5nt678vhwPanGHs4ocnq-KhvWvarSS77g_Efq2
2018-04-02 14:02:22.045 [432:123186] Returning local object of class NSString
2018-04-02 14:02:22.071 [432:123186] THREAD WARNING: ['NativeLogs'] took '47.340088' ms. Plugin should use a background thread.
2018-04-02 14:13:48.080 [432:123642] PBItemCollectionServicer connection disconnected.
2018-04-02 14:13:48.617 [432:123186] active
2018-04-02 14:13:48.617 [432:123186] PushPlugin skip clear badge
2018-04-02 14:13:52.489 [432:123186] {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":400,"statusText":"Bad Request","url":"https://api.example.com/1.0/resident/deregister-device","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://api.example.com/1.0/resident/deregister-device: 400 Bad Request","error":{"errors":{"device_token":["validation.required"]}}}

注销并尝试第二次登录

2018-04-02 14:13:52.502 [432:123186] updating address
2018-04-02 14:14:11.868 [432:123186] CDVWKWebViewEngine: handleStopScroll
2018-04-02 14:14:13.181 [432:123186] this.pages is called
2018-04-02 14:14:13.182 [432:123186] updating address
2018-04-02 14:14:13.182 [432:123186] register push called
2018-04-02 14:14:13.196 [432:123186] Push Plugin VoIP missing or false
2018-04-02 14:14:13.196 [432:127400] Push Plugin register called
2018-04-02 14:14:13.196 [432:127400] PushPlugin.register: setting badge to false
2018-04-02 14:14:13.196 [432:127400] PushPlugin.register: clear badge is set to 0
2018-04-02 14:14:13.197 [432:127400] PushPlugin.register: better button setup
2018-04-02 14:14:13.201 [432:127400] FCM Sender ID 16--752--616
2018-04-02 14:14:13.201 [432:127400] Using FCM Notification
2018-04-02 14:14:13.206 [432:123186] FCM Registration Token: cuB6DZDZMxs:APA91bHjReRv-TrwFHxsbVVAj5xeHCh56VhVEDtQ2pcLwWUrcttsA8AkOri-M3TBxXPbnkO9VsFSr1Iqzs6oOYHowx8NlEW4N3MflU5nt678vhwPanGHs4ocnq-KhvWvarSS77g_Efq2
2018-04-02 14:14:13.207 [432:123186] Push Plugin register failed
2018-04-02 14:14:13.216 [432:123186] registeration push [object Object]
2018-04-02 14:14:13.764 [432:123186] updating address

更多详情

这是我的初始化代码

this.push = PushNotification.init({
  android: {
    senderID: '168675298616',
    iconColor: '#488aff',
    clearNotifications: false,
  }
});

this.push.on('registration', (registration) => {
  console.log('registeration push', registration);
  const device = {
    device_token: registration.registrationId,
    device_type: this.platform.is('android') ? 'android' : 'ios'
  };

  this.userService.pushInit(device).subscribe(response => {
    localStorage.setItem('device_token', registration.registrationId);
  }, err => {
    console.log('silently handling registration error. :)');
  });
});

this.push.on('notification', (notification) => {
  console.log("notification", notification);

  let userdata: any = JSON.parse(localStorage.getItem('userData'));
  let addresses: any[] = userdata.member_info.addresses;
  let behaviorAddress = addresses.find(x => x.hoa_id === JSON.parse(notification.additionalData.hoa_id));
  console.log("behaviorAddress", behaviorAddress);

  if (!notification.additionalData.foreground) {
    // Do Something
  }
});

我已使用 APNs 身份验证密钥设置 Firebase

这就是功能的样子:

Xcode:

苹果开发者:

每当我通过 Xcode 交付应用程序时,我都会收到这封电子邮件:

根据电子邮件,这是我的 "aps-environment" 权利的样子:

此外,我无法将 aps-environment 设置为生产环境,它只会返回开发环境。

任何正确方向的帮助将不胜感激。

我真的想通了。问题是在构建 Cordova 期间引用了不正确的权利文件。

正确的权利文件位于:/.entitlements,而 Cordova 引用的是:/Resources/.entitlements

/Resources 没有 aps-environment

这是构建设置的样子,cordova build之后的样子