Different installationId's in Session and Installation tables

Hello guys,

I’m facing the following problem. I am working on a cross-plattform mobile app with Parse Server as backend. The client side is scripted in TypeScript and assembled using Ionic and Capacitor into two different mobile apps: one for Android and one for iOS. The login is realized directly in TypeScript code using Parse JavaScript SDK this way: await CustomUser.logIn(email, password). So far everything is good.

Some weeks ago I’ve decided to implement push notifications for both mobile apps. Therefore I had to integrate Parse SDK for Objective-C and Android into the mobile apps built with Ionic and Capacitor. The initialization of Parse works on both platforms and I was also able to verify that push notifications are arriving on both, iOS and Android. Mind: I’m using the latest versions of all three client SDK’s (JavaScript, Android, Objective-C).

But here the trouble begins: As I started to implement a cloud function to be able to target specific devices for push notifications I have noticed that the installation id’s in Session and Installation tables are completely different. Due to this mismatch I am not able to query which devices (Table Installation) belong to which user (Table User).

I suppose the reason of this mismatch is the fact I initialize Parse at two places: The TypeScript code containing the (cross-plattform) business logic of the mobile app and the native Objective-C/Android code used to enable push notifications on both platforms. So I suggest the installation id’s are generated at two different places independent from each other.

Please confirm my suggestion and - if possible - give me a hint how to resolve this issue. I have already thought about adding an additional User column to Installation table, but rejected this approach because a) an Installation must not always be connected to a user and b) I suppose it is just a matter of time I will get another problem due to the actual implementation design where Parse initialization is situated at two places.

Thanks in advance and best regards
Valdes

you can use push notifications with device ID for users with for example deviceId or distinguish.

I suggest onesignal.

Thank you, rgunindi.

Any other ideas how I could solve the issue without utilizing another services?

Not sure if I’m misinterpreting the issue, but you could pass the parse installationId in native to the TypeScript. On android save in SharedPreferences and IOS UserDefaults, then pull that out in TypeScript with capacitor/preferences so the two objects can be better linked?

java

    ParseInstallation.getCurrentInstallation().saveInBackground();
    SharedPreferences prefs = this.getSharedPreferences(
            "CapacitorStorage", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString("installId", ParseInstallation.getCurrentInstallation().getString("installationId"));
    editor.apply();

javascript side

    import { Preferences } from '@capacitor/preferences';
    const info = await Preferences.get({ key: 'installId' });
1 Like

Hello Sloq,

Yes, that’s it! Thank you so much! I solved my issue in the way you have described. After the installation ID was read from preferences it is crucial to provide it on login:

await CustomUser.logIn(credentials.email, credentials.password, { installationId: installationId.value });

Best regards
Valdes