试图通知文本中提取到活动(解析) [英] Trying to extract notification text to Activity (parse)
问题描述
我使用解析在我的应用程序推送通知,我想,以显示活动时通知文本被点击。以下是我正在努力做到这一点。
I'm using Parse for push notifications in my app and I want to show the notification text in Activity when it is clicked. Here's how I'm trying to do it.
我创建这应该处理名为PushNotification.class收到的通知一个新的活动,我创造了这个自定义类里面:
I created a new activity which is supposed to handle incoming notifications named PushNotification.class and I created this custom class inside it:
public class PushNotification extends BroadcastReceiver {
private static final String TAG = "MyCustomReceiver";
@Override
public void onReceive(Context context, Intent intent) {
try {
String action = intent.getAction();
String channel = intent.getExtras().getString("com.parse.Channel");
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
Log.d(TAG, "got action " + action + " on channel " + channel + " with:");
Iterator itr = json.keys();
while (itr.hasNext()) {
String key = (String) itr.next();
Log.d(TAG, "..." + key + " => " + json.getString(key));
}
String message = json.getString("alert");
} catch (JSONException e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
}
现在的主要问题是,这行code的不再起作用:
Now the main problem is that this line of code no longer works:
PushService.setDefaultPushCallback(this, PushNotification.class);
它强调了setDefaultPushCallback的一部分,因为appearantly它不承认PushNotification.class的活动了。
It underlines the "setDefaultPushCallback" part because appearantly it doesn't recognize PushNotification.class as Activity anymore.
我已经尝试问这个上parse.com,但我并没有得到太大的帮助那里,我需要尽快解决这个问题越好。
I already tried asking this on parse.com but I didn't get much help there and I need to solve this as soon as possible.
推荐答案
有关自定义推送通知
指定乌尔清单是这样的。
Specify like this in ur Manifest.
<service android:name="com.parse.PushService" />
<receiver
android:name="packagename.CustomParseBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="custom-action-name" />
</intent-filter>
</receiver>
在解析仪表盘,U可以手动测试设置文本消息或JSON格式推送通知。
In parse dashboard ,u can manually test push notifications by setting text as message or Json format.
实际JSON格式为:
{称号:自推的Android,OBJECTID: * 的** iuy
的objectType:类型,动作:自定义动作的名称}
{ "title": "Custom Push-Android", "objectId": "***iuy", "objectType": "type", "action": "custom-action-name" }
复制此格式和手动发送推...
Copy this format and send a push manually ...
然后创建乌尔广播类..
Then create ur broadcast class..
示例:
public class CustomParseBroadcastReceiver extends BroadcastReceiver
{
public static final String ACTION = "custom-action-name";
@Override
public void onReceive(Context context, Intent intent) {
{
}
----
----
}
我希望这有助于...............
I hope ,this helps...............
这篇关于试图通知文本中提取到活动(解析)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!