如何在后台从推送通知中获取数据?

时间:2019-06-27 12:19:36

标签: swift xcode push-notification firebase-cloud-messaging apple-push-notifications

enter image description here enter image description here enter image description here

当pushNotifications出现时,我的更新余额有问题。服务器向我发送了2个通知:第一个通知包含标题和消息,第二个通知包含数据(“金额”和“ inBalance”)。 我需要不使用点击来更新余额,当应用被杀死时,需要保存推入数据...

当我进入应用程序时,用户信息会打印: (我有两种动作类型:动作“ 2”和“ 10”)

111111 [AnyHashable("google.c.a.e"): 1, AnyHashable("aps"): {
        alert =     {
            body = "...433.";
            title = "...0438";
        };
        sound = default;
    }, AnyHashable("data"): {"action":"2"}, AnyHashable("gcm.message_id"): ..83]
    amount 0.0
    inBalance 0.0
111111 [AnyHashable("data"): {"amount":157070.0,"inBalance":37726.0,"action":"10"}, AnyHashable("google.c.a.e"): 1, AnyHashable("gcm.message_id"): ..15, AnyHashable("aps"): {
        alert =     {
            body = "";
            title = "";
        };
        sound = default;
    }]
    amount 157070.0
    inBalance 37726.0

当应用在后台打开时,以及当我点击以标记userInfo打印时: (我需要采取行动10 ...,但只能采取第二种行动)

222222 [AnyHashable("google.c.a.e"): 1, AnyHashable("data"): {"action":"2"}, AnyHashable("aps"): {
    alert =     {
        body = "...433.";
        title = "...0438";
    };
    sound = default;
}, AnyHashable("gcm.message_id"): ..95]
amount 0.0
inBalance 0.0

0 个答案:

没有答案