Commit 4358e8d7 by amateur

1

1 parent bb1c1fef
......@@ -7,6 +7,7 @@ import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.alibaba.fastjson.JSON;
import com.polysoft.nafmii.utils.ToastUtils;
import com.polysoft.nafmii.webview.JsInterfaceHandler;
import com.whaty.nafmii.R;
......@@ -53,7 +54,12 @@ public class JPushTestActivity extends AppCompatActivity implements View.OnClick
boolean pushStopped = JPushInterface.isPushStopped(this);
if (JPushInterface.isNotificationEnabled(this) == 1) {
buildLocalNotification(this,"本地标题", "通知内容");
Map<String, Object> param = new HashMap<>();
param.put("type", "learn");
Map<String, Object> urlMap = new HashMap<>();
urlMap.put("url", "http://ycjytest.cfae.cn/sites/bank/mb/my.html");
param.put("params", urlMap);
buildLocalNotification(this,"本地标题", "通知内容", param);
}
}
......@@ -62,7 +68,7 @@ public class JPushTestActivity extends AppCompatActivity implements View.OnClick
JPushInterface.setAlias(this, 10000, "123");
}
public void buildLocalNotification(Context context, String tittle, String content){
public void buildLocalNotification(Context context, String tittle, String content, Map<String, Object> extras){
JPushLocalNotification ln = new JPushLocalNotification();
ln.setBuilderId(0);
ln.setContent(content);
......@@ -70,11 +76,9 @@ public class JPushTestActivity extends AppCompatActivity implements View.OnClick
long id = System.currentTimeMillis()/1000;
ln.setNotificationId(id) ;
ln.setBroadcastTime(System.currentTimeMillis());
Map<String , Object> map = new HashMap<String, Object>() ;
map.put("name", "jpush") ;
map.put("test", "111") ;
JSONObject json = new JSONObject(map) ;
ln.setExtras(json.toString()) ;
if (null != extras) {
ln.setExtras(JSON.toJSONString(extras)) ;
}
JPushInterface.addLocalNotification(context, ln);
ToastUtils.showLong("添加本地通知,notification_id:" + id);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!