gpt4 book ai didi

android - cordova/phonegap 推送通知 unregister() 即使在关闭互联网的情况下也会返回成功

转载 作者:行者123 更新时间:2023-11-29 10:34:25 25 4
gpt4 key购买 nike

我正在使用 Phonegap 推送插件 ( https://github.com/phonegap-build/PushPlugin ) 并具有以下功能(以及成功和错误回调),当我通过切换关闭通知时调用该功能

function pushNotificationOFF() {
var pushNotification = window.plugins.pushNotification;
pushNotification.unregister(pushNotificationOffSuccess,
pushNotificationOffError);
}

function pushNotificationOffSuccess() {
alert("Noticications are OFF");
}

function pushNotificationOffError() {
alert("Error turning noticications off");
}

在 iOS7 和 Android 4.x 上,在互联网关闭(手机和 wifi)的情况下调用成功函数,我本以为会触发错误回调?

我在这里缺少什么?如何确保您不会向在设备离线时关闭它们的人发送通知?

使用测试结果编辑 2 月 4 日

ANDROID Tablet
14:12:23 wifi off
14:14:23 turned notifications off
14:18:59 wifi on
14:36:08 sent push, received


IOS tablet
15.25 wifi off
15.35 turned notifications off
15.42 wifi on
16:00 sent push, NOT received




All devices
=================================

16.30 all have wi fi on, notifications on, and receive push
16.34 turned off wifi on all
16.45 turned off notifications on all
16.55 turned ON wifi on all
17.40 sent push
17.47 not received on any device, sending another push
17.56 not received on any device


All devices 3rd feb
=================================
11.50 all have wi fi on, notifications on, and receive push
11.55 turned OFF wifi on all
12.05 turned off notifications on all and CLOSED APP
12.45 turned ON wifi on all
13.00 sent push - received by 3 x android - but not by ios and appears in ios feedback

---------------------------------

13.40 all have wi fi on, notifications on, and receive push
13.41 unplugged wifi
13.46 turned off notifications on all and CLOSED APP
14.07 turned on wifi
15.00 sent push - received by 2 x android - but not by ios and appears in ios feedback

---------------------------------


15.59 all have wi fi on, notifications on, and receive push
16.00 unplugged wifi
16.02 turned off notifications on all and backgrounded app
16.43 turned on wifi
17.41 sent push - no push received on any device and one android NotRegistered returned

SUMMARY OF TODAY

seems IOS does turn off notifications (when back online again) if toggle was changed while offline
android seems to do it also, provided
a) there is time (ie 30 min between going online again, and sending push)
b) you background app instead of closing it, after changing the toggle

最佳答案

Android documentation 所述注销不会立即发生。相反,取消注册可能需要 5 分钟才能传播。这 5 分钟内发生的事情是

During this time messages may be rejected due to the state of being unregistered, and after all this, messages may still go to the wrong user.

因此,您的注销意愿已成功收到,流程已启动,因此调用了成功回调。

这是从负责响应 JS 的 PushPlugin.java 取消注册调用的代码

GCMRegistrar.unregister(getApplicationContext());
Log.v(TAG, "UNREGISTER");
result = true;
callbackContext.success();

如您所见,它实际上可能失败的唯一情况是在 GCMRegistrar.unregister 上,它甚至不等待 GCM 服务器响应“好的,未注册”,从而导致总是返回成功。

关于android - cordova/phonegap 推送通知 unregister() 即使在关闭互联网的情况下也会返回成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27846574/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com