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

Foreground Push Notifications (Android) #358

Open
peterkuiper opened this issue Jun 24, 2024 · 9 comments
Open

Foreground Push Notifications (Android) #358

peterkuiper opened this issue Jun 24, 2024 · 9 comments
Assignees

Comments

@peterkuiper
Copy link

In an Expo project I am working on, foreground Push Notifications are "hijacked" by countly-sdk-react-native-bridge on Android. After removing countly-sdk-react-native-bridge, foreground Push Notifications on Android work as expected.

We only want to use certain parts of Countly, but not Push Notifications. I did not find any option to disable Push Notifications from within the countly-sdk-react-native-bridge package.? I tried to disable it by patching the module itself but it seems the initialization is done in the Countly Android SDK.

It would be nice to be able to opt-in to the Countly Push Notifications service.

@peterBrxwn peterBrxwn self-assigned this Jun 25, 2024
@peterBrxwn
Copy link
Contributor

peterBrxwn commented Jun 25, 2024

Hello @peterkuiper,

Are you experiencing this issue only on Android, or does it affect both platforms?

Can you elaborate more on ‘foreground Push Notifications are “hijacked” by countly-sdk-react-native-bridge on Android’?

Additionally, could you please share your SDK initialization code with us?
It would also be helpful if you could check your codebase for any instances of the following methods:

  • Countly.registerForNotification
  • Countly.askForNotificationPermission

@peterkuiper
Copy link
Author

peterkuiper commented Jun 25, 2024

Hi @peterBrxwn We are only experiencing this on Android, iOS works fine.

As said, we are using Expo Push Notifications. Without the countly-sdk-react-native-bridge module installed, push notifications are received by the Expo push notification handlers when the app is in the foreground (i.e. the app is open) and background (or killed).

With the countly-sdk-react-native-bridge module installed, push notifications work, but only when the app is in the background (or killed). So when the app is in the foreground, it seems the countly-sdk-react-native-bridge module handles the incoming push notification, instead of the Expo push notification module. Hence the "hijacking".

This is the init function:

const enableCountlyAsync = async () => {
  if (__DEV__) {
    return false;
  }

  // Setup Countly
  try {
    const initialized = await Countly.isInitialized();

    if (!initialized) {
      // Disable Countly internal debugging logs
      Countly.setLoggingEnabled(false);

      // Require consent for all features
      Countly.setRequiresConsent(true);

      // Ensure that consent is required for features to work
      Countly.giveConsentInit(['events', 'views', 'sessions', 'scrolls', 'clicks']);

      // Initialize the countly SDK.
      await Countly.init(localConfig.countly.url, localConfig.countly.appKey);

      // Disable location tracking
      Countly.disableLocation();

      // Start session tracking
      Countly.start();

      return true;
    }
  } catch (error) {
    if (__DEV__) {
      console.log('[enableCountlyAsync]', 'catch', error); // eslint-disable-line no-console
    }
  }

  return false;
};

These methods aren't called anywhere in our code:

  • Countly.registerForNotification
  • Countly.askForNotificationPermission

We only use the Countly.recordView method.

@peterBrxwn
Copy link
Contributor

Hi @peterkuiper,

Thank you for your prompt response.

Quick question: What version of the Countly SDK are you using?

@peterkuiper
Copy link
Author

@peterBrxwn I tried until version 23.12.0, same issue. The current version in production use is 21.11.2.

@jdodds-pxhealthcare
Copy link

@peterBrxwn Any updates on this yet ?

thanks!

@peterBrxwn
Copy link
Contributor

@jdodds-pxhealthcare

We are currently investigating the issue. We will provide an update as soon as possible.

@pavelPX
Copy link

pavelPX commented Jul 15, 2024

Hi @peterBrxwn !
Is there any updates with this issue?

@peterBrxwn
Copy link
Contributor

Hello @pavelPX,
We are working on a no push variant. Should be available within this month. I will post it here when it is ready.

@pavelPX
Copy link

pavelPX commented Jul 16, 2024

Great news! Thank you @peterBrxwn

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

4 participants