OneSignal-Flutter-SDK icon indicating copy to clipboard operation
OneSignal-Flutter-SDK copied to clipboard

[Bug]: External Id not set when logging users [iOS]

Open cgmleadtech opened this issue 1 year ago • 22 comments

What happened?

In iOS I'm logging a user with a certain Id and the external id is not being placed in OneSignal

Steps to reproduce?

1. Initialize and Login into OneSignal with any external Id
`await OneSignal.login('test_id');`
2. Retrieve the OneSignal ID and check if the external id used when logging in works
(it does not)

What did you expect to happen?

I would have expected the external id worked

OneSignal Flutter SDK version

5.0.2

Which platform(s) are affected?

  • [X] iOS
  • [ ] Android

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

cgmleadtech avatar Oct 04 '23 13:10 cgmleadtech

@cgmleadtech Thank you for reaching out! I am not able to reproduce this can you clarify what you mean by "it doesn't work"

emawby avatar Oct 06 '23 19:10 emawby

Hi @emawby , so basically when I do the login with a revenuecat ID the external ID is not being set at all

await OneSignal.login(revenueCatUserID);

revenueCatUserID is not null, obviously hahaha

cgmleadtech avatar Oct 09 '23 07:10 cgmleadtech

I'm facing same issue. not setting external ID for both Android and iOS.

sharad-paghadal avatar Oct 11 '23 12:10 sharad-paghadal

@sharad-paghadal Thank you for the log that is helpful. Unfortunately I am not able to reproduce this but I will keep investigating. Does your app have identity verification enabled?

emawby avatar Oct 11 '23 22:10 emawby

thank you @emawby , that was the issue. Just turned off identity verification and everything is working!!

sharad-paghadal avatar Oct 12 '23 04:10 sharad-paghadal

@emawby I do not have identity verification enabled, and if I add as external id any kind of string, not just the revenuecatid, it does not work users still appears as: Screenshot 2023-10-13 at 12 52 50

cgmleadtech avatar Oct 13 '23 10:10 cgmleadtech

@emawby thank you for the tip! I have faced the same Problem, turned the identity verification to disable, with solved my issue. It's nice to see, that there are no hints on the documentation.

RicBau2610 avatar Oct 19 '23 14:10 RicBau2610

@cgmleadtech, it seems you're using both OneSignal and RevenueCat. So am I (for an unreleased Flutter app). But for the integration to work, according to RevenueCat's documentation, the app needs to send $onesignalId to RevenueCat's user attributes:

image

But I can't find a way to get the OneSignal ID in v.5.0.3.

Onesignal ID was previously available in v3.x.x but now only the subscription ID and the token are available from the Onesignal.User.pushSubscription.id property.

How can I get it?

How are you integrating OneSignal and RevenueCat if you're not using the OneSignal ID?

Thanks :)

jmmdk avatar Nov 01 '23 15:11 jmmdk

@cgmleadtech, it seems you're using both OneSignal and RevenueCat. So am I (for an unreleased Flutter app). But for the integration to work, according to RevenueCat's documentation, the app needs to send $onesignalId to RevenueCat's user attributes:

image

But I can't find a way to get the OneSignal ID in v.5.0.3.

Onesignal ID was previously available in v3.x.x but now only the subscription ID and the token are available from the Onesignal.User.pushSubscription.id property.

How can I get it?

How are you integrating OneSignal and RevenueCat if you're not using the OneSignal ID?

Thanks :)

I think you can read the migration guide and that actually the push subscription.id is what you are looking for but mayb I'm wrong

@emawby could you clarify this?

cgutierr-zgz avatar Nov 01 '23 18:11 cgutierr-zgz

Identity verification is not yet supported and still in development. @RicBau2610: you're right, this limitation should be clear in documentation. We will work on updating all our docs.

@jmmdk and @cgutierr-zgz: the OneSignal ID can be retrieved via our REST API or our Server SDKs using the

  1. View user endpoint
  2. View user identity endpoint
  3. View user identity (by subscription) endpoint

The OneSignal ID is different from the Push Subscription ID.

We see the need to be able to get the OneSignal ID from the SDK, and will be adding a getter.

nan-li avatar Nov 01 '23 23:11 nan-li

@cgmleadtech, I am also not able to reproduce. Is this is only happening on iOS?

  1. Is this consistent behavior or random?
  2. Is this on a new app install? This is the first time login is called?
  3. Can you turn on logging to VERBOSE with OneSignal.Debug.setLogLevel(LogLevel.Verbose) BEFORE you call OneSignal.initialize(APP_ID) and share logs from the time you call login?

nan-li avatar Nov 01 '23 23:11 nan-li

@nan-li, thanks for your response.

However, I just got a response to my message to your support and they say that we should simply send RevenueCat the Subscription ID instead of the OneSignal ID (contrary to the RC docs).

So is support wrong and the docs are correct? If so, that means that we can't actually integrate with RC because you don't have a getter for that OneSignal ID? We don't use the REST API/server SDK. And if that's true, how fast can you add that getter? We really need that ASAP.

jmmdk avatar Nov 02 '23 08:11 jmmdk

We see the need to be able to get the OneSignal ID from the SDK, and will be adding a getter.

Yeah I think you really just need a getter because I can already read the onesignalId from the debug prints so I guess it's there?

D/OneSignal(30889): [Thread-41] OperationRepo.enqueueAndWait(operation: {"name":"refresh-user","appId":"049c6e09-dea1-4649-84f9-c695a********","onesignalId":"a7ef6ff9-9b4b-4121-aa21-c0b7*******"}, force: true)

rignaneseleo avatar Nov 02 '23 09:11 rignaneseleo

Any updates on this topic?

RogerBrusamarello avatar Nov 22 '23 01:11 RogerBrusamarello

Hi, is there any update on the OneSignal ID getter?

monkapepega avatar Dec 18 '23 07:12 monkapepega

i think if you are all only want to get the Onesignal ID, you just use this OneSignal.User.pushSubscription.id

trymersi avatar Dec 21 '23 08:12 trymersi

@nan-li @emawby

I was facing the same issue. in my case, my external ID (ex: 46644) has more than 200 subscriptions. I used rest api to set exteranl ID to subscription, the response says "meta":{"user_subscription_limit":200}}

but OneSignal.login(46644) with sdk didn't return any error message.

I deleted all subscriptions linked with my external ID then it works.

chaos128 avatar Feb 20 '24 13:02 chaos128

In my case, OneSignal.login(session.user.id); doesn't work on iOS, but OneSignal.login("${session.user.id}"); works fine, and external_id is set correctly.

tamamura3 avatar Jun 15 '24 08:06 tamamura3

Hi everyone, I apologize for the delayed response. If you are managing at the user-level rather than device-level (which is what the subscription ID effectively does), please use the OneSignal ID as the identifier.

The get method was added in Release 5.1.3.

nan-li avatar Jun 16 '24 16:06 nan-li

Hi @chaos128, the login method itself will not return an error, but logs should show the error response once the request is made to the OneSignal server.

Hi @tamamura3, the login method requires a string for the external ID passed in. It appears session.user.id itself is not a string and needed to be stringified?

nan-li avatar Jun 16 '24 16:06 nan-li

Hm I also have an issue that externalId is not set up properly and I am receiving such an error. I don't use aliases 🤔 Package version: 5.2.2 image

EDIT: I found a separate thread for my issue https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/714

LiLatee avatar Jul 24 '24 15:07 LiLatee

Hello Everyone, Finally We have fixed with @SabirHalil In ios when user not accepted notification and one signal permission and you request for login that time it not set external id you must be sure to user accepted permission than login and it will works fine

OneSignal.Notifications.addPermissionObserver((state) { print("Has permission " + state.toString()); if (state) { print("Has permission Accepted" + state.toString()); setUserExternalId(); } }); you can use like that and it will works.

sorosons avatar Sep 19 '24 22:09 sorosons