小编Ank*_*dal的帖子

尽管响应成功,Firebase 推送通知未显示在手机上

在使用 Postman 进行测试时,我通过FCM API将推送令牌发送到特定设备,但我打算从服务器发送它们。

{
    "to" : "my_device_token",
    "notification" : {
        "notificationTitle" :"test from server",
        "notificationBody" :"test lorem ipsum"
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到回复

{
    "multicast_id": 4996861050764876123,
    "success": 1,
    "failure": 0,
    "canonical_ids": 0,
    "results": 
    [
        {
            "message_id": "0:1519567530487886%f95ee7d4f95ee123"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这显示没有错误,但是我的手机上没有收到任何通知。我在 firebase 网站“通知 => 新消息 => 单个设备”上尝试使用相同的设备令牌,并且它有效。

我看到有关在应用程序未运行时未收到通知的线程,但是即使应用程序正在运行,我也没有收到任何通知。

编辑:如果相关,我的应用程序是使用 Xamarin.Android 构建的。

android push-notification xamarin.android firebase firebase-cloud-messaging

5
推荐指数
1
解决办法
5794
查看次数

当用户离开时清除 sessionStorage?

sessionStorage.setItem当有人点击按钮时我会触发该事件。

sessionStorage.setItem('save', saved);
Run Code Online (Sandbox Code Playgroud)

这很好,但是 jQuery 有没有办法sessionStorage在用户以任何方式离开页面时删除它?

到目前为止我找到的答案。。。

$(window).on("beforeunload", function() {
    $.ajax("someURL", {
        async: false,
        data: "test",
        success: function(event) {
             console.log("Ajax request executed");
        }
    });
    return "This is a jQuery version";
});
Run Code Online (Sandbox Code Playgroud)

。。。AJAX 看起来很复杂。

但我正在寻找一些更简单的方法来做到这一点?

html javascript ajax jquery

0
推荐指数
1
解决办法
1832
查看次数