Skip to content
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

Notification listener not working with expo 52 #97

Open
happyshittake opened this issue Jan 23, 2025 · 9 comments
Open

Notification listener not working with expo 52 #97

happyshittake opened this issue Jan 23, 2025 · 9 comments

Comments

@happyshittake
Copy link

happyshittake commented Jan 23, 2025

hello, we are in the process of updating our expo based app from expo 50 to 52, we are stuck with somehow pushy notification didnt trigger the js callback, we checked in the logcat attached below the notification indeed being received by the device, tried with newArch enabled and disabled the same, and we also already tried using the latest sdk, this is our build.gradle deps

  // Pushy SDK for Android
    implementation 'me.pushy:sdk:1.0.121'
    
    // Pushy SDK for React Native Android
    implementation 'me.pushy:sdk-react-native:1.0.22'

Image

@pushy
Copy link
Owner

pushy commented Jan 23, 2025

Hi @happyshittake,
Thanks for reaching out. We'd be glad to assist with your inquiry.

If your React Native Expo project makes use of expo-router, please create a file called app/App.tsx with the following contents:

import 'expo-router/entry'

Then, modify your project's package.json and find the following line:

"main": "expo-router/entry"

Replace with:

"main": "app/App.tsx",

This is necessary for being able to process push notifications with the app in the background/killed state using HeadlessJS.

Please give it a try, and let us know if there's anything else we can help with.

@pushy pushy closed this as completed Jan 23, 2025
@happyshittake
Copy link
Author

umm we don't actually use expo router, we use react navigation and we already set the main to index.js since expo 50

@pushy
Copy link
Owner

pushy commented Jan 23, 2025

Hi @happyshittake,
Thanks for confirming.

Please ensure your project is using the latest Pushy RN JS SDK by running the following command:

npm install pushy-react-native@latest --save

@pushy pushy reopened this Jan 23, 2025
@happyshittake
Copy link
Author

yes i've tried updating the package aswell i confirmed it's using 1.0.41 i assume that would be the latest right?

@pushy
Copy link
Owner

pushy commented Jan 23, 2025

Hi @happyshittake,
Yes, that is the latest version at this time. Thanks for confirming.

Can you please confirm whether your invocation of the Pushy.setNotificationListener() method has been placed inside your App.tsx right after the import statements, any outside any component lifecycle method declaration? It cannot be placed in any other file or location.

@happyshittake
Copy link
Author

Image

yes this should be outside the component

@pushy
Copy link
Owner

pushy commented Jan 23, 2025

Hi @happyshittake,
It appears your invocation is missing the async keyword, please try using this callback parameter instead to see if it resolves the issue:

Pushy.setNotificationListener(async data => {
    // Print notification payload data
    console.log('Received notification: ' + JSON.stringify(data));

    // Notification title
    let notificationTitle = 'MyApp';

    // Attempt to extract the "message" property from the payload: {"message":"Hello World!"}
    let notificationText = data.message || 'Test notification';

    // Android: Displays a system notification
    // iOS: Displays an alert dialog
    Pushy.notify(notificationTitle, notificationText, data);

    // Clear iOS badge count
    Pushy.setBadge(0);
});

@happyshittake
Copy link
Author

Image

it does return async funciton, this code is working on expo 50 tho

@pushy
Copy link
Owner

pushy commented Jan 23, 2025

Hi @happyshittake,
Thanks for confirming.

We will attempt to test using Expo 52 to see if we can reproduce and resolve the issue. This will take a few days.

Thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants