package com.demo.app.push;
|
|
import android.content.Context;
|
import android.content.Intent;
|
import android.util.Log;
|
|
import com.demo.lib.common.util.common.StringUtils;
|
|
import org.json.JSONException;
|
import org.json.JSONObject;
|
|
import cn.jpush.android.api.CustomMessage;
|
import cn.jpush.android.api.NotificationMessage;
|
import cn.jpush.android.service.JPushMessageReceiver;
|
|
public class MyJpushReceiver extends JPushMessageReceiver {
|
|
|
private static final String TAG = MyJpushReceiver.class.getSimpleName();
|
|
//注册成功
|
@Override
|
public void onRegister(Context context, String s) {
|
super.onRegister(context, s);
|
Log.i(TAG, "onRegister:" + s);
|
if (StringUtils.isEmpty(s)) {
|
return;
|
}
|
//获取token
|
//TODO 上传token
|
}
|
|
//收到消息
|
|
|
@Override
|
public void onMessage(Context context, CustomMessage customMessage) {
|
super.onMessage(context, customMessage);
|
}
|
|
@Override
|
public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) {
|
super.onNotifyMessageArrived(context, notificationMessage);
|
Log.i(TAG, "收到通知消息:" + notificationMessage.toString());
|
}
|
|
@Override
|
public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
|
super.onNotifyMessageOpened(context, notificationMessage);
|
//intent:#Intent;component=com.yeshi.makemoney.video/.app.push.PushOpenClickActivity;end
|
Log.i(TAG, "通知打开:" + notificationMessage.toString());
|
String extra = notificationMessage.notificationExtras;
|
if (StringUtils.isEmpty(extra)) {
|
return;
|
}
|
try {
|
JSONObject json = new JSONObject(extra);
|
String type = json.optString("type");
|
String params = json.opt("params") + "";
|
context.startActivity(PushOpenClickActivity.createIntent(context, type, params));
|
} catch (JSONException e) {
|
e.printStackTrace();
|
}
|
|
}
|
|
@Override
|
public void onMultiActionClicked(Context context, Intent intent) {
|
super.onMultiActionClicked(context, intent);
|
Log.i(TAG, "onMultiActionClicked");
|
}
|
}
|