- 初始化 Parse
- 接收 Parse Push Message
- 發送 Push Message
這次我們要做第二點的延伸
延伸?
簡單的說,Parse SDK 有預設
但我們想自己做 Design 這樣可以嗎??
Notification Icon、Notification Message ...etc.
Notification Icon、Notification Message ...etc.
當然是可以的
1 . extends ParsePushBroadcastReceiver
( ex : is ParsePushBroadcastReceiver, isn't ParseBroadcastReceiver )
( ex : is ParsePushBroadcastReceiver, isn't ParseBroadcastReceiver )
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.parse.ParsePushBroadcastReceiver;
public class MyParseReceiver extends ParsePushBroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d("MyParseReceiver", "action:" + action);
}
}
You can add key in onReciver
- String strChannel = intent.getExtras().getString("com.parse.Channel");
- String strData = intent.getExtras().getString("com.parse.Data");
2 . 將原先的註冊的 Receiver 更改
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>
( 更改成剛剛繼承的 Receiver )
<receiver
android:name="MyParseReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>
3 . 如果覺得原生的 Notification 太單調,也可以改成自己的
// 將提醒功能取消
@Override
protected Notification getNotification(Context context, Intent intent) {
return null;
}
private void myNotification(...){
Notification...
}
歡迎轉載,請註明出處。
沒有留言:
張貼留言