Deeplink problem when application working in the background (Braze provider), React Native, iOS

169 Views Asked by At

I'm facing an issue with deeplinks when sending from braze account. Deeplinks should open me some let's say popup in the app. When the app is closed and I send a push notification from Braze, I will receive it on my ios mobile device, when I click it, it will redirect me to the onboarding page (if deeplink is set to be "onboarding"), but if my app is working in background and I receive push notification with deeplink, when I click that push notification it will just open the app and it will not navigate me to the wanted screen.

I have appDelegate.mm file and this is defined inside it

// Deep Linking
- (BOOL)application:(UIApplication *)application
   openURL:(NSURL *)url
   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  NSLog(@"Calling RCTLinkingManager with url %@", url);
  return [RCTLinkingManager application:application openURL:url options:options];
}

// Universal links
- (BOOL)application:(UIApplication *)application
  continueUserActivity:(NSUserActivity *)userActivity
  restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler
{
  return [RCTLinkingManager application:application
                   continueUserActivity:userActivity
                     restorationHandler:restorationHandler];
}

and also inside app.tsx I have

setupLinking = async () => {
    // Listen to links opened when the app is closed
    const initialLink = await Linking.getInitialURL();

    if (initialLink) {
      this.onURLEvent({ url: initialLink });
    }

    // Listen to links opened in the app or when the app is in background
    Linking.addEventListener('url', this.onURLEvent);
  };

onURLEvent = async (event: { url: any; }) => {
    const { url } = event;

    if (!url) {
      return;
    }

    const link = getLinkFromDynamicLink(url);
    const eventMethod = getMethodFromLink(link);
}
0

There are 0 best solutions below