Commit 22566ddf by baijinqiu

实现通知、点击通知跳到指定路由、app图标显示数值的功能

parent 2169fce0
......@@ -3,8 +3,6 @@
<component name="ChangeListManager">
<list default="true" id="2e775c3f-ff13-4f54-ba20-3e0eeadc9822" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/plugin.xml" beforeDir="false" afterPath="$PROJECT_DIR$/plugin.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/android/ONService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/ONService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/android/onservice/HandleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/onservice/HandleService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/android/onservice/NotificationService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/onservice/NotificationService.java" afterDir="false" />
</list>
......@@ -58,6 +56,7 @@
<workItem from="1589766857083" duration="2925000" />
<workItem from="1589791590396" duration="2832000" />
<workItem from="1589860449552" duration="2327000" />
<workItem from="1589938957473" duration="5615000" />
</task>
<servers />
</component>
......
......@@ -22,7 +22,7 @@ public class HandleService extends IntentService {
protected void onHandleIntent(@Nullable Intent intent) {
// Log.e(TAG, "onHandleIntent: userId "+ intent.getStringExtra("userId"));
// Log.e(TAG, "onHandleIntent: schoolId "+ intent.getStringExtra("schoolId"));
Log.e(TAG, "onHandleIntent: object "+ intent.getStringExtra("object"));
Log.e(TAG, "onHandleIntent: object " + intent.getStringExtra("object"));
// NotificationService.webView.loadUrl(intent.getStringExtra("url"));
NotificationService.cordovaPlugin.getActivity().runOnUiThread(new Runnable() {
@Override
......@@ -35,6 +35,12 @@ public class HandleService extends IntentService {
@Override
public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
NotificationService.cordovaPlugin.getActivity().startActivity(new Intent(NotificationService.cordovaPlugin.getContext(), MainActivity.class));
NotificationService.cordovaPlugin.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
NotificationService.webView.loadUrl("javascript:cordova.plugins.notification.badge.decrease(1)");
}
});
// Log.e(TAG, "onStartCommand: userId "+ intent.getStringExtra("userId"));
// Log.e(TAG, "onStartCommand: schoolId "+ intent.getStringExtra("schoolId"));
// Log.e(TAG, "onStartCommand: url " + intent.getStringExtra("url"));
......
......@@ -176,10 +176,18 @@ public class NotificationService extends Service {
.setContentTitle(content.messageTitle)
.setContentIntent(pendingIntent)
.setContentText(content.body)
.setNumber(2)
// .setAutoCancel(true)
.build();
notification.flags = Notification.FLAG_AUTO_CANCEL;
// notification.flags = Notification.FLAG_AUTO_CANCEL;
// 是否允许清除通知
// notification.flags |= Notification.FLAG_NO_CLEAR;
cordovaPlugin.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
webView.loadUrl("javascript:cordova.plugins.notification.badge.increase(1)");
}
});
manager.notify(Integer.parseInt(content.id), notification);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment