Appcelerator iOS推送通知显示在前台

时间:2018-09-17 18:41:41

标签: ios push-notification apple-push-notifications appcelerator appcelerator-titanium

当前使用以下内容处理iOS设备上的推送通知。

Ti.App.iOS.addEventListener("usernotificationsettings", function registerForPush() {

    Ti.App.iOS.removeEventListener("usernotificationsettings", registerForPush);

    Cloud.Users.login({
        login: "user",
        password: "12345"
    }, function (e) {

        if (e.success) {

           Ti.Network.registerForPushNotifications({
                success: function(e){

                    Cloud.PushNotifications.subscribeToken({
                        channel: "AppAlerts",
                        device_token: e.deviceToken,
                        type: "ios"
                    }, function(e){
                        alert("subscribed");
                    });

                },
                error: function(e){
                    alert(e.error);
                },
                callback: function(e){
                    alert(e);
                }
            });

         }
    }); 

});

我能够注册设备令牌,而对Appcelerator没有任何问题。当应用程序在后台运行并且用户单击推送通知时,将调用回调,并且我能够读取有效负载。但是,当应用程序位于前台时,会显示通知横幅(就像该应用程序仍在后台一样)。单击横幅或收到横幅时,永远不会调用该回调。

Example

这似乎发生在装有iOS 10以上版本的设备上。装有9.3.5的设备没有问题。

1 个答案:

答案 0 :(得分:0)

我设法通过使用Titanium SDK 7.2.0 GA构建应用程序来实现了这一目标。该应用程序以前使用7.3.1 GA和7.4.0 GA。

相关问题