New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to trigger a deep link from a local notification? #485
Comments
I'm working on this now. You can use the notification listener to grab notification details and use your router (in my case react-native-router-flux) to trigger the desired action and show the right view. If you're using URL schemes seems like Crossroads is the routing lib of choice for projects like this. @shimatai your thumbs up indicates this maybe solved your issue. Is that the case? If so, @evollu you can probably close this. |
The notification listener doesn't works as I expect, because I want to route to a screen only if the user clicks on the message in the notification bar. Actually, when app receives a push notification and user clicks on notification, nothing happens. I know that notification listener can route to a screen, but I want to route only if the user clicks on Android notification bar. |
@shimatai you can check if the notif has |
If the user receives a push notification with the app closed, the registered listener is not being triggered. What's the solution for this issue? Is there anyway to trigger a method in my app when receiving a push notification with the app closed? |
put the listener outside of the component lifecycle, just like what readme does. |
@shimatai - did you manage to resolve this? if yes then how? |
@shekharskamble I had to create a Java class that extends For example: import com.evollu.react.fcm.MessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.Set;
public class MyAppMessagingService extends MessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Set<String> keys = remoteMessage.getData().keySet();
for (String key : keys) { // List all keys inside incoming message
Log.i("MyAppMessagingService", "Key " + key + ": " + remoteMessage.getData().get(key));
}
super.onMessageReceived(remoteMessage);
}
} |
@shimatai - thanks for the example but how are you triggering deep link from onMessageReceived? |
@shekharskamble No, that piece of code is in the native side (it's a Java class that extends the MessagingService of react-native-fcm). This code is to receive a push notification when the app is closed (not in background nor in use). In my case, when the app receives a notification, my app saves the content in a key (that is read by React Native's AsyncStorage when the app is launched again). I had to do this because my users can receive notifications while not using the app and the listener written in JavaScript is not triggered. The deep link is triggered by react-native-fcm. I didn't need to register a deep link. |
Hi,
How can I trigger a deep link from a
FCM.presentLocalNotification
?I'm using React Native 0.45.0 with react-native-fcm 7.0.3 and I'm running in a real Android device and in an emulator too.
All notifications are working well, but I didn't find a way to load a deep link when the user press on the local notification (showed on the Android notification bar).
The text was updated successfully, but these errors were encountered: