OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
625 stars 214 forks source link

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

Open cgmleadtech opened 1 year ago

cgmleadtech commented 1 year ago

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?

Relevant log output

No response

Code of Conduct

emawby commented 1 year ago

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

cgmleadtech commented 1 year ago

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

sharad-paghadal commented 1 year ago

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

emawby commented 1 year ago

@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?

sharad-paghadal commented 1 year ago

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

cgmleadtech commented 1 year ago

@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
RicBau2610 commented 1 year ago

@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.

jmmdk commented 1 year ago

@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 :)

cgutierr-zgz commented 1 year ago

@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?

nan-li commented 1 year ago

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 commented 1 year ago

@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?
jmmdk commented 1 year ago

@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.

rignaneseleo commented 1 year ago

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)

RogerBrusamarello commented 1 year ago

Any updates on this topic?

monkapepega commented 11 months ago

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

trymersi commented 11 months ago

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

chaos128 commented 9 months ago

@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.

tamamura3 commented 5 months ago

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.

nan-li commented 5 months ago

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 commented 5 months ago

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?

LiLatee commented 4 months ago

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

sorosons commented 2 months ago

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.