braze-inc / braze-react-native-sdk

Public repo for the Braze React Native SDK
https://www.braze.com
Other
64 stars 84 forks source link

[Bug]: getInitialPushPayload function always return pushPayload as undefined (with @braze/expo-plugin) #271

Closed drweizak closed 2 weeks ago

drweizak commented 1 month ago

Which Platforms?

iOS

Which React Native Version?

0.75.4

Which @braze/react-native-sdk SDK version?

13.1.0

Repro Rate

100% of the time

Steps To Reproduce

  1. Set this Code:

    useEffect(() => {
    const getStartupUrl = async (): Promise<string> => {
      const market = await selectRegion();
      let deepLinkUrl = await Linking.getInitialURL();
      await new Promise<void>(resolve => {
        // Handle deep link for iOS app killed case
        // Ensuring proper functionality by using export default,
        // Read more: https://github.com/braze-inc/braze-react-native-sdk/issues/166#issuecomment-2072816870
        // eslint-disable-next-line import/no-named-as-default-member
        Braze.getInitialPushPayload(
          (pushPayload: PushNotificationEvent | null) => {
            if (pushPayload?.url) {
              deepLinkUrl = pushPayload.url;
            }
            resolve();
          },
        );
      });
      if (queuedNotificationEvent.current) {
        deepLinkUrl = queuedNotificationEvent.current.url;
        queuedNotificationEvent.current = null;
      }
    
      return constructStartupUrl(market.url, deepLinkUrl);
    };
    
    void getStartupUrl();
    }, []);
  2. Create a push notification campaign with a On-click behavior to a your-app-schema://path-to-your-app

Expected Behavior

On notification click with the app killed after opened, the pushPayload should contain an object with the url key.

Actual Incorrect Behavior

On notification click with the app killed after opened, the pushPayload is undefined

Verbose Logs

No response

Additional Information

Using expo and setting up my native app via app.config file with expo `@braze/expo-plugin'. I have not done any changes to:

application:didFinishLaunchingWithOptions:launchOptions:: [[BrazeReactUtils sharedInstance] populateInitialPayloadFromLaunchOptions:launchOptions];

jerielng commented 1 month ago

Hey @drweizak, thanks for raising this! We're still in the process of porting these changes over into the Braze Expo plugin, so if you are not integrating that populateInitialPayload method in Objective-C, that payload will return null on launches from a terminated state. We will keep you updated when this has been released on Expo. Thanks!

drweizak commented 1 month ago

Thank you so much for the clarification.

Should I close it? Or maybe re-title it to have expo reference, so others can come and see it?

jerielng commented 1 month ago

Thanks for re-titling. That will help for visibility. We can keep this issue open as a way to keep you updated when we have released a corresponding update for the Expo plugin.

jerielng commented 2 weeks ago

Hey @drweizak, we've released 3.0.0 of the Braze Expo plugin, so you should now be able to receive a valid payload. Feel free to reach back out if you have further questions. Thanks!