gpt4 book ai didi

android - 解析.com : Sending a localized push notification to Android client - what does the client implementation look like?

转载 作者:行者123 更新时间:2023-11-30 01:38:57 24 4
gpt4 key购买 nike

我希望完全按照描述的方式做 in this question , 但发送到 Android 客户端。 Android客户端如何正确处理alert<中的loc-keyloc-argsaction-loc-key参数 对象?

云代码:

Parse.Push.send({
where: pushQuery,
data: {
title: title,
alert: {
"loc-key":"msg",
"loc-args":["John"],
"action-loc-key":"rsp"
},
type: type
}
}

Android 客户端如何正确处理这些键并本地化推送?我是否必须手动子类化 Parse 广播接收器?

最佳答案

是的,你必须继承 Parse Broadcast 接收器

首先,在 list 中声明一个接收器

        <receiver android:name="com.example.PushReceiver" android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>

然后创建一个 ParsePushBroadcastReceiver 子类并覆盖 onReceive 方法。

    public class PushReceiver extends ParsePushBroadcastReceiver{
@Override
public void onPushReceive(Context context, Intent intent) {

try {
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));

//This is where you get your values
JSONObject alertObject = json.getJSONObject("alert");

} catch (JSONException e) {
e.printStackTrace();
}
}
}

关于android - 解析.com : Sending a localized push notification to Android client - what does the client implementation look like?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34763579/

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