hms-react-native-plugin
hms-react-native-plugin copied to clipboard
"react-native-hms-push" drops data from intent that leads to broke Linking.getInitialUrl()
When I click by deeplink await Linking.getInitialUrl()
returns null.
If to remove react-native-hms-push from package.json everything works properly.
It loks like the problem is somewhere here:
com/huawei/hms/rn/push/remote/HmsPushMessaging.java:300
in sendOpenedNotificationData
method
public void sendOpenedNotificationData(Intent intent) {
try {
Map<String, Object> map = new HashMap<>();
Bundle extras = intent.getExtras();
if (extras != null) {
RemoteMessage remoteMessage = new RemoteMessage(extras);
map.put("remoteMessage", RemoteMessageUtils.toMap(remoteMessage));
JSONObject extrasData = BundleUtils.convertJSONObject(extras);
map.put("extras", extrasData);
}
if (intent.getDataString() != null)
map.put("uriPage", intent.getDataString());
HmsPushMessaging.setInitialNotification(map);
getContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(Core.Event.NOTIFICATION_OPENED_EVENT, MapUtils.copyToWritableMap(map));
intent.setFlags(0);
intent.replaceExtras(new Bundle());
intent.setData(intent.getData());
} catch (Exception e) {
Log.w(TAG, "sendOpenedNotificationData: " + e.getLocalizedMessage());
}
}
intent.setData(intent.getData());
I think you should add more specific checking (in com/huawei/hms/rn/push/remote/HmsPushMessaging.java:275 [checkFlag]) if intent has notification data or not to avoid loosing data.
@lexgorbunov I am facing the same problem, did you find a solution, please?
Same issue using @hmscore/[email protected]
and using dynamic links of firebase @react-native-firebase/dynamic-links@^14.11.0
. Every call to dynamicLinks()..getInitialLink()
returns null
when the app is opened by a valid dynamic link. Uninstalling @hmscore/react-native-hms-push
the problem is gone.
@lexgorbunov did you get a workaround to solve this?
Hi all,
There is an ongoing development for this issue yet the current scope of the solution only covers the firebase/dynamic-links issue. You may try this solution for the issue or share your demo file for us to check any other edge cases.
Please remove the logic which are added below from the line 278 at node_modules/@hmscore/react-native-hms-push/android/src/main/java/remote/HmsPushMessaging.java
intent.getDataString() != null
Thank you for reporting the issue to us.
We released the 6.5.0.300 version of Push a few days ago. This version contains some bug fixes related to clear intent data. The issue you mentioned has been fixed with the latest version.