app head: fix launch urls and notification target urls

This commit is contained in:
Akinwale Ariwodola 2019-10-31 07:55:36 +01:00
parent 9ffaba4358
commit fb497cebfe
3 changed files with 18 additions and 12 deletions

2
app

@ -1 +1 @@
Subproject commit f714310681fa430aa84a4121ccca322bd2d6fd8e
Subproject commit 943c5654c1cf7d9246964a3bc8826cffd2ae92f4

View file

@ -534,17 +534,6 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.cancel(sourceNotificationId);
}
// check for target (notification payload)
String target = intent.getStringExtra("target");
if (target != null && target.trim().length() > 0) {
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
WritableMap params = Arguments.createMap();
params.putString("url", target);
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onNotificationTargetLaunch", params);
}
}
}
super.onNewIntent(intent);

View file

@ -396,4 +396,21 @@ public class UtilityModule extends ReactContextBaseJavaModule {
editor.commit();
}
}
@ReactMethod
public void getNotificationLaunchTarget(Promise promise) {
Activity activity = MainActivity.getActivity();
if (activity != null) {
Intent intent = activity.getIntent();
if (intent != null) {
String target = intent.getStringExtra("target");
if (target != null && target.trim().length() > 0) {
promise.resolve(target);
return;
}
}
}
promise.resolve(null);
}
}