静默通知不会在 TestFlight 中发送

Silent Notifications Won't Send In TestFlight

我的应用严重依赖静默通知向用户发送数据。此功能在开发中运行良好,但当我使用 TestFlight 进行测试时,它不起作用。我读到这可能是某些 iOS 版本中的错误,但我不是 运行 中的任何一个。我正在使用 parse 发送推送通知,它说通知已发送,但它没有执行任何代码 didReceiveRemoteNotification 有谁知道为什么这不起作用?

Parse.Push.send({
    where: pushQuery,
    data: {
        "content-available" : 1,
        "sound" : "",
        "time" : alarmTimeDate,
    },
    push_time: alarmTime
}, { }).then(function() {
    response.success("Push was sent successfully.")
}, function(error) {
    response.error("Push failed to send with error: "
+ error.message);
});
},

error: function(user, error) { // error is an instance of Parse.Error. } });

 });

在开发中,我假设您使用的是与您在 Parse 上配置的推送证书相关联的开发配置文件。

当您使用 TestFlight 时,您需要使用发布配置文件。该配置文件将绑定到不同的推送证书。因此,如果您尚未配置发布推送证书(并在您的应用程序 ID 上启用推送以进行分发),这就是您在 TestFlight 构建中看不到推送的原因。

我以前没有使用 Parse 进行推送,但例如在 Urban Airship 中,它们使您可以轻松地为单个应用配置开发和发布证书。

希望对您有所帮助!

所以我终于得出了结论。在 iOS 中,8 个静默通知并不能保证在使用生产证书时执行 didReceiveRemoteNotification 中的代码。在开发中,它的工作方式与 iOS 7 中的相同,但在生产中不同。您可以阅读更多相关信息 here. "Apple are not acknowleding this change in background behaviour as a bug, they acknowledge the change but say its intentional." - mungbeans

希望这对有同样问题的人有所帮助,很抱歉通知您这个消息。因此,我需要重建我的整个应用程序。