|
|
@@ -82,8 +82,93 @@ export const PushNotificationProvider = ({ children }: { children: React.ReactNo
|
|
|
}, [appState]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (lastNotificationResponse && Platform.OS === 'android') {
|
|
|
+ if (lastNotificationResponse) {
|
|
|
const data = lastNotificationResponse.notification.request.content.data;
|
|
|
+ let screenName;
|
|
|
+ let url;
|
|
|
+ let parentScreen;
|
|
|
+ let params;
|
|
|
+ if (Platform.OS === 'ios') {
|
|
|
+ parentScreen = (
|
|
|
+ lastNotificationResponse.notification.request
|
|
|
+ .trigger as Notifications.PushNotificationTrigger
|
|
|
+ )?.payload?.parentScreen;
|
|
|
+ screenName = (
|
|
|
+ lastNotificationResponse.notification.request
|
|
|
+ .trigger as Notifications.PushNotificationTrigger
|
|
|
+ )?.payload?.screen;
|
|
|
+ params = (
|
|
|
+ lastNotificationResponse.notification.request
|
|
|
+ .trigger as Notifications.PushNotificationTrigger
|
|
|
+ )?.payload?.params;
|
|
|
+ url = (
|
|
|
+ lastNotificationResponse.notification.request
|
|
|
+ .trigger as Notifications.PushNotificationTrigger
|
|
|
+ )?.payload?.url;
|
|
|
+
|
|
|
+ if (screenName && parentScreen) {
|
|
|
+ if (params) {
|
|
|
+ const parsedParams = JSON.parse(params as string) ?? {};
|
|
|
+
|
|
|
+ navigation.dispatch(
|
|
|
+ CommonActions.reset({
|
|
|
+ index: 1,
|
|
|
+ routes: [
|
|
|
+ {
|
|
|
+ name: 'DrawerApp',
|
|
|
+ state: {
|
|
|
+ routes: [
|
|
|
+ {
|
|
|
+ name: parentScreen as string,
|
|
|
+ state: {
|
|
|
+ routes: [
|
|
|
+ { name: NAVIGATION_PAGES.MAP_TAB },
|
|
|
+ {
|
|
|
+ name: screenName as string,
|
|
|
+ params: parsedParams
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ navigation.dispatch(
|
|
|
+ CommonActions.reset({
|
|
|
+ index: 1,
|
|
|
+ routes: [
|
|
|
+ {
|
|
|
+ name: 'DrawerApp',
|
|
|
+ state: {
|
|
|
+ routes: [
|
|
|
+ {
|
|
|
+ name: parentScreen as string,
|
|
|
+ state: {
|
|
|
+ routes: [
|
|
|
+ { name: NAVIGATION_PAGES.MAP_TAB },
|
|
|
+ {
|
|
|
+ name: screenName as string
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (url) {
|
|
|
+ Linking.openURL(url as string);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (data?.screen && data?.parentScreen) {
|
|
|
if (data?.params) {
|
|
|
@@ -186,6 +271,7 @@ export const PushNotificationProvider = ({ children }: { children: React.ReactNo
|
|
|
let groupToken;
|
|
|
let messageId;
|
|
|
let fromUser;
|
|
|
+
|
|
|
if (Platform.OS === 'ios') {
|
|
|
const parsedData =
|
|
|
JSON.parse(
|
|
|
@@ -218,6 +304,7 @@ export const PushNotificationProvider = ({ children }: { children: React.ReactNo
|
|
|
url = (response.notification.request.trigger as Notifications.PushNotificationTrigger)
|
|
|
?.payload?.url;
|
|
|
}
|
|
|
+ console.log('33333', screenName, parentScreen);
|
|
|
|
|
|
if (screenName && parentScreen) {
|
|
|
if (params) {
|