infobip / mobile-messaging-react-native-plugin

Mobile Messaging SDK plugin for React Native projects
24 stars 4 forks source link

Every time an user installs an app update, a new installation is registered in his profile. #66

Closed jorgerojas26 closed 1 month ago

jorgerojas26 commented 6 months ago

When an user install an App update from the store, the next time he opens the app, a new installation is registered in his "Persons" profile, so, as it shows in the picture below, the user now has 2 installations, and when i send a push notification to that user email, the infobip is sending 2 pushes, one for both installations, but the older one always throws the following error: Expired pushRegistrationId (code 8001).

How do i prevent this behavior? i don't want to register a new installation for every app update. Our user base on "Persons" module is ful of garbage installations because of this.

image

Package version:

"infobip-mobile-messaging-react-native-plugin": "8.4"

SDK Initialization on index.js:

mobileMessaging.supportedEvents.forEach(event => {
    mobileMessaging.subscribe(event, handleMobileMessagingEvent);
});

mobileMessaging.init(
    {
        applicationCode: app_settings.infobip.appCode,
        ios: { notificationTypes: ['alert', 'badge', 'sound'] },
    },
    () => {},
    error => {
        console.log('MobileMessaging error: ', error?.description);
    }
);
...
AppRegistry.registerRunnable(appName, props => {
    AppRegistry.registerComponent(appName, () => App);
    TrackPlayer.registerPlaybackService(() => Player);
    AppRegistry.runApplication(appName, props);
});

After user login:

mobileMessaging.personalize(
            {
                userIdentity: {
                    emails: [email],
                    externalUserId: id
                },
                userAttributes: {
                    firstName: first_name,
                    lastName: last_name,
                    customAttributes,
                },
                forceDepersonalize: true,
            },
            user => console.log('infobip user personalized', { user }),
            error => console.error('infobip user personalized error', { error })
);
alboldy-ib commented 6 months ago

Hello,

  1. App updates should not create new registrations, you should check your implementation thoroughly. If app storage is cleaned - if someone cleans the data on Android for example, then the new registration will be created. From analysing few registrations I was able to find successful updates without reissuing registration id (person profile ids 14854, 31861, event - Push contact changed, property: app version, from: 3.5.2, to: 3.6.0).

  2. There are a lot of personalize/depersonalize calls. If your app has user sessions, it is better to perform personalize/depersonalize only on login/logout, as described here - https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Personalization-implementation-for-mobile-apps-with-authorization

In case you need additional support or help with handling any sensitive private account data, please forward your request to support@infobip.com

riskpp commented 1 month ago

Closing the issue because no additional questions or comments appeared for a long time.