Open peterkuiper opened 5 days ago
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
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.
Hi @peterkuiper,
Thank you for your prompt response.
Quick question: What version of the Countly SDK are you using?
@peterBrxwn I tried until version 23.12.0
, same issue. The current version in production use is 21.11.2
.
In an Expo project I am working on, foreground Push Notifications are "hijacked" by
countly-sdk-react-native-bridge
on Android. After removingcountly-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.