Onesignal-flutter-sdk: setExternalUserId() works randomly on iOS

Created on 4 Oct 2019  路  15Comments  路  Source: OneSignal/OneSignal-Flutter-SDK

Description:

setExternalUserId() sometimes does not set the external_user_id on iOS. Retrying sometimes solve this issue and the external_user_id is correctly set.

In the next screenshot you can see that the iPhone9,3 was not able to setUserExternalId() after notifications subscribe:

image

Environment

I'm using Flutter 1.9.1+hotfix.4 and onesignal_flutter: ^2.1.0

Steps to Reproduce Issue:

    1.
OneSignal.shared.init(appId, iOSSettings: {
      OSiOSSettings.autoPrompt: true,
      OSiOSSettings.inAppLaunchUrl: true
    });

2.

OneSignal.shared
        .setInFocusDisplayType(OSNotificationDisplayType.notification);

3.

bool _requiresConsent = await OneSignal.shared.requiresUserPrivacyConsent();

4.
```
await OneSignal.shared.consentGranted(true);
//Set subscription
OneSignal.shared.setSubscription(true);

5.

static Future setSpecificUserId(String userId) async {
await OneSignal.shared.setExternalUserId(userId);
}
```

Anything else:

I'm using iOS 13.1.2 on iPad 2018 (6th gen)

Help Wanted Possible Bug

All 15 comments

Thanks for your patience while we investigate

@rgomezp sorry and thank you for your active support on this repo, but I think it is my problem. Sometimes I call removeExternalUserId() and setExternalId() before privacy consent requiring

W/OneSignal( 8432): Method removeExternalUserId() was called before the user provided privacy consent. Your application is set to require the user's privacy consent before the OneSignal SDK can be initialized. Please ensure the user has provided consent before calling this method. You can check the latest OneSignal consent status by calling OneSignal.userProvidedPrivacyConsent()
W/OneSignal( 8432): Method setExternalId() was called before the user provided privacy consent. Your application is set to require the user's privacy consent before the OneSignal SDK can be initialized. Please ensure the user has provided consent before calling this method. You can check the latest OneSignal consent status by calling OneSignal.userProvidedPrivacyConsent()

Now I need to test my new code for some days then I can confirm you if this code error is the cause of my problem

At the moment I'm trying to refactor my code but I have a problem related to the fact that OneSignal.userProvidedPrivacyConsent() does not exist.

UPDATE: anyway on iOS the SDK behavior is not always the same. The same code that one Android works perfectly on iOS sometimes works and sometimes no

Thanks for your update. Were you able to resolve?

At the moment no, the same code on Android works perfectly (tested with a lot of devices of different manufacturer) but on iOS it often does not work. It happen that the device subscribe correctly to notifications but the external user id is set randomly.
In the free time I'm trying to write a test app to show you this behavior but at the moment I'm very busy.

About OneSignal.userProvidedPrivacyConsent() have you got any info? Is it a removed method missed in the docs?

That method does not exist in the Flutter SDK. Please let us know when you come up with a repro app

Closing due to no response

I am having this same problem. Works all the time in Android, but iOS some of the time. Usually works after repeated calls of SetExternalUserId. I am using Xamarin and not Flutter. My code is simple. I do not call the RemoveExternalUserId at all.

Additionally the call SendTags works every single time on both Android and iOS. I have tried using the UserDidProviderPrivacyConsent(true) and that doesn't solve the problem.

Check the logs I get the following message.
WARNING: Attempted to set external user id, but [id] is already set

It appears the call only lets one device have the external id. However this is an issue because the app can be used on multiple devices and we wish to notify all devices associated with that account using that accounts external id.

Any help would be greatly appreciated.

Howdy Chris,
Edit: previous response was wrongly stated. Please disregard.

Thanks for your patience while we investigate further.

@enricobenedos & @chrisparkeronline

Are you using setExternalUserId or removeExternalUserId in combo with our setEmail method?

Also we now offer setExternalUserId and removeExternalUserId with a callback in OneSignal Flutter SDK 2.4.0. You should use this instead of making multiple calls to set and remove methods.

Example for new callback:

String externalUserId = "123456789";
OneSignal.shared.setExternalUserId(externalUserId).then((results) {
    if (results == null) return;
    // Now use the results of the call for each channel (push and email)
});

Hi @mikechoch
Using the Xamarin Forms SDK setExternalUserId callback version of the method seems to work for me. Thanks for the help.

hey @mikechoch, sorry for late response but no, I'm not using setEmail method. At the moment the project I was develop has been stopped. At the moment I'm experiencing a similar issue with a new project using simply await OneSignal.shared.setSubscription(). At the moment I'm a little bit frustrated with this library. There are a lot of behaviour difference between iOS and Android, and the official documentation sometimes is not updated due to the closed GitHub issues

Hi, issue still there on version 3.0.0-beta2

@gilthonweapps Hello, I am having trouble reproducing this issue. Are you able to provide some details around when you are calling setExternalUserId and what you are seeing on the dashboard?

Was this page helpful?
0 / 5 - 0 ratings