handle intent extras for background notifications

This commit is contained in:
Akinwale Ariwodola 2019-10-29 16:08:40 +01:00
parent 7114bf2c96
commit 9f1eb5b7f9
3 changed files with 17 additions and 6 deletions

2
app

@ -1 +1 @@
Subproject commit 065e91bfb467c7537c8d54c0727e7a2e500e6bae
Subproject commit fc1ef26a17a74536443620c3cc9b6cd29edeea9b

View file

@ -45,7 +45,7 @@ public class LbrynetMessagingService extends FirebaseMessagingService {
String url = null;
if (payload != null) {
type = payload.get("type");
url = payload.get("url");
url = payload.get("target");
}
if (type != null && getEnabledTypes().indexOf(type) > -1) {

View file

@ -80,7 +80,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
private static final int PHONE_STATE_PERMISSION_REQ_CODE = 202;
private static final int RECEIVE_SMS_PERMISSION_REQ_CODE = 203;
public static final int DOCUMENT_PICKER_RESULT_CODE = 301;
private BroadcastReceiver notificationsReceiver;
@ -297,7 +297,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
};
registerReceiver(smsReceiver, smsFilter);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
@ -307,7 +307,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
}
}
}
if (requestCode == DOCUMENT_PICKER_RESULT_CODE) {
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
@ -534,6 +534,17 @@ 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);
@ -637,7 +648,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
return array;
}
/**
* https://gist.github.com/HBiSoft/15899990b8cd0723c3a894c1636550a8
*/