|
17 | 17 | import com.facebook.react.bridge.ReactContextBaseJavaModule; |
18 | 18 | import com.facebook.react.bridge.ReactMethod; |
19 | 19 | import com.facebook.react.bridge.ReadableArray; |
| 20 | +import com.facebook.react.bridge.ReadableMap; |
20 | 21 | import com.facebook.react.bridge.WritableArray; |
21 | 22 | import com.facebook.react.bridge.WritableMap; |
22 | 23 | import com.facebook.react.modules.core.DeviceEventManagerModule; |
@@ -121,6 +122,16 @@ public void resumePush() { |
121 | 122 | Logger.toast(mContext, "Resume push success"); |
122 | 123 | } |
123 | 124 |
|
| 125 | + @ReactMethod |
| 126 | + public void crashLogOFF() { |
| 127 | + JPushInterface.stopCrashHandler(getReactApplicationContext()); |
| 128 | + } |
| 129 | + |
| 130 | + @ReactMethod |
| 131 | + public void crashLogON() { |
| 132 | + JPushInterface.initCrashHandler(getReactApplicationContext()); |
| 133 | + } |
| 134 | + |
124 | 135 | @ReactMethod |
125 | 136 | public void notifyJSDidLoad(Callback callback) { |
126 | 137 | // send cached event |
@@ -157,8 +168,10 @@ private static void sendEvent() { |
157 | 168 | .emit(mEvent, map); |
158 | 169 | break; |
159 | 170 | case CONNECTION_CHANGE: |
160 | | - mRAC.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) |
161 | | - .emit(mEvent, mCachedBundle.getBoolean(JPushInterface.EXTRA_CONNECTION_CHANGE, false)); |
| 171 | + if (mCachedBundle != null) { |
| 172 | + mRAC.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) |
| 173 | + .emit(mEvent, mCachedBundle.getBoolean(JPushInterface.EXTRA_CONNECTION_CHANGE, false)); |
| 174 | + } |
162 | 175 | break; |
163 | 176 | } |
164 | 177 | mEvent = null; |
@@ -446,7 +459,7 @@ public void onReceive(Context context, Intent data) { |
446 | 459 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
447 | 460 | } else { |
448 | 461 | intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); |
449 | | - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 462 | + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
450 | 463 | } |
451 | 464 | intent.putExtras(mCachedBundle); |
452 | 465 | context.startActivity(intent); |
@@ -575,6 +588,26 @@ public void jumpToPushActivity(String activityName) { |
575 | 588 |
|
576 | 589 | } |
577 | 590 |
|
| 591 | + @ReactMethod |
| 592 | + public void jumpToPushActivityWithParams(String activityName, ReadableMap map) { |
| 593 | + Logger.d(TAG, "Jumping to " + activityName); |
| 594 | + try { |
| 595 | + Intent intent = new Intent(); |
| 596 | + if (null != map) { |
| 597 | + while (map.keySetIterator().hasNextKey()) { |
| 598 | + String key = map.keySetIterator().nextKey(); |
| 599 | + String value = map.getString(key); |
| 600 | + intent.putExtra(key, value); |
| 601 | + } |
| 602 | + } |
| 603 | + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 604 | + intent.setClassName(mRAC, mRAC.getPackageName() + "." + activityName); |
| 605 | + mRAC.startActivity(intent); |
| 606 | + } catch (Exception e) { |
| 607 | + e.printStackTrace(); |
| 608 | + } |
| 609 | + } |
| 610 | + |
578 | 611 | @ReactMethod |
579 | 612 | public void finishActivity() { |
580 | 613 | try { |
|
0 commit comments