iOS 推送通知:找不到有效连接 [英] iOS Push Notification: cannot find vaild connection

查看:51
本文介绍了iOS 推送通知:找不到有效连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在本地解析服务器上设置推送通知.尝试发送推送时出现此错误:

I'm trying to setup push notifications on my local parse server. I get this error when trying to send a push:

parse-server-push-adapter APNS 找不到 9a86...21 的有效连接

(对于每个安装设备令牌都会重复该错误.)

(The error repeats for every installation device token.)

有什么想法吗?

我的服务器代码:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  
  liveQuery: {
    classNames: ["Mission"]
  },
  filesAdapter: new S3Adapter(
    process.env.S3_ACCESS_KEY || '',
    process.env.S3_SECRET_KEY || '',
    process.env.S3_BUCKET || '',
    {directAccess: true}
  ),
  push: {
    ios: {
      pfx: 'certificates/development.p12',
      bundleId: 'co.example.myApp',
      production: false // Dev
    }
  }
});

我正在从我的云代码中推送:

I'm pushing from my cloud code:

var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.containedIn('user', specificUser);
Parse.Push.send({
  where: installationQuery,
  data: {
    "alert": "Loren ipsum ",
    "id": MyCustomId
  }
}, { useMasterKey: true }, {
  success: function() {
    console.log("Push was successful!");
  },
  error: function(error) {
    console.error(error);
  }
});

推荐答案

导致错误的原因是您在安装表中有一个设备与 push 请求上的过滤器不再匹配在 Apple 为您的应用程序注册.当 Apple 收到对不再注册到您的应用程序的设备的通知请求时,它会返回该消息以指示如果它继续发生,您应该采取一些措施.

What cause the error is that you have a device in the installation table that matched the filter on the push request that is no longer registered in Apple for your app. When Apple receives a request for a notification to a device that is no longer registered to your application it returns that message to indicate you should take some action if it continues to happen.

就我而言,我在安装表中注册了四台与我的 push 过滤器匹配的设备,其中两台设备不再在 Apple 中为我的应用注册,因此每次推送时都会出现该错误对于每个无效的安装.

In my case I have four devices registered in the installation table that matched my push filter and two of those devices are no longer registered in Apple for my app so every time I push it get that error for each of invalid installations.

我不确定为什么会发生这种情况,但我已经看到以下情况会导致创建新的安装记录,使之前的安装无效.在收到该设备令牌的这么多错误后,解析服务似乎可以监控并采取行动,而在错误之间没有成功推送.

I'm not sure why it happens but I've seen the following scenarios that causes a new installation record to be created that invalidates the prior installation. It seems like something the parse service could monitor and take action for after getting so many errors for that device token with no successful pushes between errors.

  1. 用户删除并重新安装应用
  2. 用户更新了他们的 iOS 版本,deviceToken 值发生了变化.
  3. 解析服务的连接 URL 通过更改配置设置在应用中更新,而无需重新安装应用.

要解决错误,您只需删除与错误消息中的 deviceToken 匹配的安装

To resolve the errors you simply need to remove the installation that matches the deviceToken in the error message

这篇关于iOS 推送通知:找不到有效连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆