Closed Chasty closed 1 week ago
UPDATE: adding the alias with key external_id
seems to do the trick; it updates the external id, no matter which value is set in the alias external_id
OneSignal.User.addAlias('external_id', 'userId-test-1')
OneSignal.login(userId)
but getting an issue.
PATCH RECEIVED JSON: {"errors":[{"code":"user-2","title":"One or more Aliases claimed by another User","meta":{"external_id":"userId-test-1"}}]}
/identity - FAILED STATUS: 409
Operation execution failed without retry: "label":"external_id","value":"userId-test-1","id":"16a36673-19bc-440d-9276-8143aea8751f"}]
Hi @Chasty, Thank you for reporting.
Can you share more logs from when you call OneSignal.login(YOUR_EXTERNAL_ID)
? This log you shared only shows the operations the SDK is about to send to the server, and does not provide much information about what happens after. Can you share more logs after this point so we can see what is happening?
[OpRepo] UpdateUserOperationExecutor(operation: [{"name":"set-tag","appId":"APP_ID,"onesignalId":"0804ec65-6139-4997-8360-2a51c568c62f","key":"user_type","value":"free","id":"73f04223-7046-4ef3-9d59-f3a5211af2ea"}, {"name":"set-tag","appId":"APP_ID","onesignalId":"0804ec65-6139-4997-8360-2a51c568c62f","key":"user_privileges","value":"user","id":"096d9d5a-a763-4122-b1b5-9a36066dc8fb"}, {"name":"set-tag","appId":"APP_ID","onesignalId":"0804ec65-6139-4997-8360-2a51c568c62f","key":"user_name","value":"iphone X","id":"d3aadb7e-f008-4fe8-9820-1fa38569cf43"}, {"name":"login-user","appId":"APP_ID","onesignalId":"local-be9c0dc1-99c3-4cb3-a6b8-d9ed6b5a9fbd","externalId":"63e2e8d44f28ce00147b5faf","existingOnesignalId":"0804ec65-6139-4997-8360-2a51c568c62f","id":"2c2d4187-bd93-48ab-adec-77cc0c356b7c"}])
The 409 "user-2" error you see for OneSignal.User.addAlias('external_id', 'userId-test-1')
means you are trying to add this external_id to the user that has onesignalId of 0804ec65-6139-4997-8360-2a51c568c62f
. However, the external_id of 'userId-test-1'
already exists on a different user with a different onesignalId.
Aliases are unique user identifiers and should not be freely moved from one user to another. You can use the View User API to see details about the user that has the external_id
of userId-test-1
.
In the SDK, if you are trying to login to an external_id, you should be using the login
method, not the addAlias
method. This is because the SDK will handle this 409 "user-2" error.
@nan-li adding this OneSignal.User.addAlias('external_id', 'userId-test-1')
before login OneSignal.login(MY_EXTERNAL_ID)
actually solves my issue. The first issue here is that MY_EXTERNAL_ID
is not linked or set for my particular user.
so the second issue may be expected, but I did not use aliases before, and I'm not concerned about this issue right now because our app is working as expected.
I could reproduce this with an app from scratch. I'll make sure to add logs shortly.
UPDATE: I think the second issue should not happen because I'm adding that external_id alias like this OneSignal.User.addAlias('external_id', 'MY_EXTERNAL_ID')
and getting the exact same issue.
@nan-li here are the logs after OneSignal.login(63e2e8d44f28ce00147b5faf)
, still not set.
[mqt_native_modules] addEmail(email: weyweyxd123@gmail.com)
[mqt_native_modules] SubscriptionManager.addSubscription(type: EMAIL, address: weyweyxd123@gmail.com)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"create-subscription",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","subscriptionId":"local-f28f29b2-e1c9-49e8-9fa2-c9bb883831ab","type":"EMAIL","enabled":true,"address":"weyweyxd123@gmail.com","status":"SUBSCRIBED"}, flush: false)
[mqt_native_modules] setTag(key: user_type, value: free)
[mqt_native_modules] setTag(key: user_privileges, value: user)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"set-tag",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","key":"user_type","value":"free"}, flush: false)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"set-tag",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","key":"user_privileges","value":"user"}, flush: false)
[mqt_native_modules] setTag(key: user_name, value: iphone X)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"set-tag",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","key":"user_name","value":"iphone X"}, flush: false)
[mqt_native_modules] login(externalId: 63e2e8d44f28ce00147b5faf, jwtBearerToken: null)
[mqt_native_modules] createAndSwitchToNewUser()
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"transfer-subscription",""appId" "APP_ID"","subscriptionId":"1a6cae57-6bc3-4828-8567-8555bceb2531","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76"}, flush: false)
[Thread-81] OperationRepo.enqueueAndWait(operation: {"name":"login-user",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","externalId":"63e2e8d44f28ce00147b5faf","existingOnesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909"}, force: true)
[mqt_native_modules] addEmail(email: weyweyxd123@gmail.com)
[mqt_native_modules] SubscriptionManager.addSubscription(type: EMAIL, address: weyweyxd123@gmail.com)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"create-subscription",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","subscriptionId":"local-13362878-de30-41d5-9660-a126590b7e96","type":"EMAIL","enabled":true,"address":"weyweyxd123@gmail.com","status":"SUBSCRIBED"}, flush: false)
[mqt_native_modules] setTag(key: user_type, value: free)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"set-tag",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","key":"user_type","value":"free"}, flush: false)
[mqt_native_modules] setTag(key: user_privileges, value: user)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"set-tag",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","key":"user_privileges","value":"user"}, flush: false)
[mqt_native_modules] setTag(key: user_name, value: iphone X)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"set-tag",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","key":"user_name","value":"iphone X"}, flush: false)
[mqt_native_modules] login(externalId: 63e2e8d44f28ce00147b5faf, jwtBearerToken: null)
[mqt_native_modules] OperationRepo.enqueue(operation: {"name":"refresh-user",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76"}, flush: true)
[OpRepo] SubscriptionOperationExecutor(operations: [{"name":"create-subscription",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","subscriptionId":"local-f28f29b2-e1c9-49e8-9fa2-c9bb883831ab","type":"EMAIL","enabled":true,"address":"weyweyxd123@gmail.com","status":"SUBSCRIBED","id":"24fccd8a-92d6-4f61-8ba0-8c44930d013e"}])
[DefaultDispatcher-worker-1] HttpClient: POST apps/ee982b05-fba9-44b9-9ee3-eb432c40d1f2/users/by/onesignal_id/95d3bc67-26a3-4657-99db-ce10d2f5c909/subscriptions - {"subscription":{"type":"Email","token":"weyweyxd123@gmail.com","enabled":true,"notification_types":1,"sdk":"050000","device_model":"sdk_gphone64_arm64","device_os":"13","rooted":false,"net_type":0,"carrier":"T-Mobile","app_version":"1"}}
[DefaultDispatcher-worker-1] HttpClient: POST apps/ee982b05-fba9-44b9-9ee3-eb432c40d1f2/users/by/onesignal_id/95d3bc67-26a3-4657-99db-ce10d2f5c909/subscriptions - STATUS: 202 JSON: {"subscription":{"id":"5b5017ab-71e9-43ed-93d0-01324f375b56","app_id":"ee982b05-fba9-44b9-9ee3-eb432c40d1f2","type":"Email","token":"weyweyxd123@gmail.com","enabled":true,"notification_types":-99,"session_time":520018,"session_count":164,"sdk":"040805","device_model":"Redmi Note 9 Pro","device_os":"10","rooted":false,"test_type":0,"app_version":"2079714183","net_type":0,"carrier":"#VAMOSPERU","web_auth":"","web_p256":""}}
[OpRepo] OperationRepo: execute response = SUCCESS
[OpRepo] UpdateUserOperationExecutor(operation: [{"name":"set-tag",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","key":"user_type","value":"free","id":"c4f47834-12f4-4fd2-a59b-b93ddd323111"}, {"name":"set-tag",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","key":"user_privileges","value":"user","id":"d37dd3e4-fa5b-4c79-a1d2-b4cd838e0e74"}, {"name":"set-tag",""appId" "APP_ID"","onesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","key":"user_name","value":"iphone X","id":"9aa7ec60-46e5-4d77-8ad2-fa4a84892a30"}, {"name":"login-user",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","externalId":"63e2e8d44f28ce00147b5faf","existingOnesignalId":"95d3bc67-26a3-4657-99db-ce10d2f5c909","id":"3c794b10-a424-406c-914f-42f0a38d17de"}, {"name":"set-tag",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","key":"user_type","value":"free","id":"08c02adf-3f56-4cee-9a06-24104649b806"}, {"name":"set-tag",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","key":"user_privileges","value":"user","id":"19fdefdc-1763-4bc0-9c20-6ed9e67012e2"}, {"name":"set-tag",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76","key":"user_name","value":"iphone X","id":"f034f8f0-f53e-4a44-9102-9346c5454267"}])
[DefaultDispatcher-worker-3] HttpClient: PATCH apps/ee982b05-fba9-44b9-9ee3-eb432c40d1f2/users/by/onesignal_id/95d3bc67-26a3-4657-99db-ce10d2f5c909 - {"refresh_device_metadata":false,"properties":{"tags":{"user_type":"free","user_privileges":"user","user_name":"iphone X"}}}
[DefaultDispatcher-worker-3] HttpClient: PATCH apps/ee982b05-fba9-44b9-9ee3-eb432c40d1f2/users/by/onesignal_id/95d3bc67-26a3-4657-99db-ce10d2f5c909 - STATUS: 202 JSON: {"properties":{"tags":{"user_name":"iphone X","user_privileges":"user","user_type":"free"}}}
[OpRepo] OperationRepo: execute response = SUCCESS
[Thread-81] OperationRepo.enqueueAndWait(operation: {"name":"refresh-user",""appId" "APP_ID"","onesignalId":"local-876bbeb1-e4d4-453c-927f-8e7935d25e76"}, force: true)
Same issue there, I had to set OneSignal.User.addAlias('external_id', id)
before the login
@ajouve @Chasty @nan-li Anyone please help me how get player id / External ID react native oneSignal version 5+
const state = await OneSignal.getDeviceState(); const userID = state.userId;
this is not working how to get external ID and Subscription ID
@FazilMuhammed external ID is the userId
from your user in your own database.
@nan-li i am also getting this issue when upgrading to the newest onesignal library
2023-10-19 15:02:24.858 OneSignal E Operation execution failed without retry: [{"name":"login-user","appId":"e4b404e3-f5ee-4f9b-a69d-0c2bdb87589d","onesignalId":"local-3209dbe0-3bfe-4de7-ae18-e49842950e22","externalId":"2531197224","existingOnesignalId":"4914a1f4-1da8-444d-87ba-601b7a58086d","id":"2aa07e9f-0b63-48b5-80d4-153625aa152b"}, {"name":"transfer-subscription","appId":"e4b404e3-f5ee-4f9b-a69d-0c2bdb87589d","subscriptionId":"0671cc21-6536-40d9-889e-f87fba046088","onesignalId":"local-3209dbe0-3bfe-4de7-ae18-e49842950e22","id":"1c8c0386-b982-4f31-a468-139faa67f541"}, {"name":"create-subscription","appId":"e4b404e3-f5ee-4f9b-a69d-0c2bdb87589d","onesignalId":"local-3209dbe0-3bfe-4de7-ae18-e49842950e22","subscriptionId":"local-7d842b68-4633-4de9-9e56-a274b4a01f0d","type":"EMAIL","enabled":true,"address":"elfeel67@gmail.com","status":"SUBSCRIBED","id":"c481b5e2-66f9-4129-9bb7-6e03965c6fae"}] 2023-10-19 15:02:24.949 OneSignal E Could not login user
Login is failing and user user doesn't have an external id because of this failure
I've the same issue for Android sdk, is there any one solved the issue? thanks!
OneSignal.User.addAlias('external_id', 'userId-test-1') OneSignal.login(userId)
I have tried this but still not able to set external id. below is my code "react-native-onesignal": "^5.0.2",
useEffect(() => {
//OneSignal Init Code
// Remove this method to stop OneSignal Debugging
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize(cloudFunctionConfig.OneSignalAppID);
}, []);
useEffect(() => {
if (user) {
try {
OneSignal.User.addAlias('external_id', 'userId-test-1');
OneSignal.login(user?.uid);
} catch (error) {
console.log(error);
}
}
}, [user]);
@Chasty Could you please help?
I've the same issue for Android sdk, is there any one solved the issue? thanks!
Have you found a solution for this? I've the same issue.
@Juanli07 I have to downgrade the version to 4.8.6 and it is working well!
@MohammedShehata could you shared to me the library initialization with that version? thanks!
@MohammedShehata I tried to install and says Couldn't find any versions for "react-native-onesignal" that matches "4.8.6"
I have the same issue in iOS and Android, and it works fine in version 4.5.2
. Also, the new version doesn't have a way to specify the identity hash for authenticating the user, which is really necessary to ensure a safe subscription. Please advise here if there is a workaround in the latest version or a way to do this.
// How it works with 4.5.2
OneSignal.setEmail(email, null);
OneSignal.setExternalUserId(_id, identityHash, results => {
console.log(results);
});
any updates here?
please resolve it
Please help me, I am getting the same bug on the IOS external id field still empty, OneSignal.login("id_test_01") not working on Unity with OneSignal 5.0.5 SDK.
@minhit1805 in my case, I've apps in iOS and android, and in both cases I had to downgrade the SDK version.
Same here. OneSignal.login(pushId) does not put an external_id value which i can check through onesignal dashboard.
Someone has been able to fix this? OneSignal.login(ExternalID) seems to do not work at all
@programmerxx89 I faced this issue but in the native side, I tried to downgrade the version of one signal and it is working now!
i solved the issue by downgrading to onesignal 4.5.2
We're facing the same problem after upgrading to v5. This is the official OneSignal SDK for React Native, isn't it? I'm really disappointed. 😒
OneSignal.login(ExternalID)
works for me on v5.0.5
It might not work if OneSignal is not fully initialized when the login function is called.
What I have done to overcome this challenge is that I initialized OneSignal
in the root screen (App.tsx) as usual and then I call OneSignal.login(ExternalID)
first in the App.tsx
screen and call it again in my Dashboard Screen when I'm sure that OneSignal must have been initialized. I also check to make sure that the ExternalID
also is not null.
I hope this helps someone
Edit: In addition, OneSignal.User.pushSubscription.addEventListener('change', myListener);
can also come in handy to effect the login. I have also used this technique to get it done
Well if u pushing just id in string example OneSignal.login("1") or OneSignal.login("5") it won't work. Just add OneSignal.login("user-id-${userId}") it fixed that issue for me.
Also in settings/keys_and_ids on OneSignal web i've changed: Identity Verification for email + external_id (recommended) to off.
I got the same issue in OneSignal latest version (5.1.3) in Flutter.
The OneSignal.login("External_Id") is not setting ID and in the dashboard, it shows that the external ID has not been set for a particular user, in my case the external ID is for one user, but this user has more than one devices.
Any Updates on this issue?
We having the same issue here (5.1.0) on Android. After method .login(ID), on iOS it works well, but on Android, is External ID keep empty on Dashboard.
test
Is this permanent solution or temporary one?
This happens randomly on iOS too. We are able to get subscription ID and save it in our logs but calling OneSignal.User.login does not save the externalID in dashboard. We use latest Flutter SDK.
Also experiencing random cases of a subscription having no external id at all in my React Native app (both for Android and iOS). Hoping to try some of the suggested workarounds here; but that will have to wait in my case.
Same here, external id is being set or not set randomly.
The same problem here, the external id is not set when logging in ios and android.
It is a pitty they do not investigate this further. We wrote several cases to technical support with explicit ID's to investigate in their logs. We decided to look for other similar platforms as alternatives as we have several clients affected by this anomalies.
În joi, 20 iun. 2024 la 05:00 Arthur BL @.***> a scris:
The same problem here, the external id is not set when logging in ios and android.
— Reply to this email directly, view it on GitHub https://github.com/OneSignal/react-native-onesignal/issues/1565#issuecomment-2179678627, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAJSJGJ5JGQQLEKHYX4RXTZIIZTHAVCNFSM6AAAAAA5AHOXRSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGY3TQNRSG4 . You are receiving this because you commented.Message ID: @.***>
We came across this problem with the external ids being null. Our workaround is using the OneSignal IDs instead. OneSignal is changing their user model to use the OneSignal IDs. These ids appear to be consistent upon situations when the app installs/loads or when users change devices.
Instead of using the external_id in your notification code use the onesignal_id for your alias, which seems more consistent and reliable.
@budostylz hi bro, can you share please how can I get the one signal_id? im getting null
//app.js
OneSignal.initialize(appKey);
OneSignal.Notifications.requestPermission(true);
const OneSignalUserID = await OneSignal.User.getOnesignalId(); //get onesignal id
OneSignal.User.addEmail(userEmail);
OneSignal.User.addAlias('onesignal_id', OneSignalUserID); //set alias
OneSignal.login(UID);
//function to persist one signal id in data store
updateNotificationIDToDataStore(UID, OneSignalUserID);
//payload to send notification
const alias = await getOneSignalIDFromDataStore();
let data = {
app_id: `${appKey}`,
include_aliases: { onesignal_id: [alias] }, //use onesignal id in alias
target_channel: "push",
isIos: true,
contents: {
en: message,
},
.......
};
Just keep your version before v5. OneSignal.login() is much worse than OneSignal.setExternalUserId().
OneSignal proved to be unreliable. We switched to Firebase Messaging which is free and more reliable than OneSignal. The only caveat is creating your own analytics.
it was ok until this happened, not sure why they are not able to track this down, we offered detailed logs and phonenumbers... we moved to airship
On Fri, Jul 19, 2024 at 1:23 PM Shaun Lewis @.***> wrote:
OneSignal proved to be unreliable. We switched to Firebase Messaging which is free and more reliable than one signal. The only caveat is creating your own analytics.
— Reply to this email directly, view it on GitHub https://github.com/OneSignal/react-native-onesignal/issues/1565#issuecomment-2238849319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAJSJF76I43DB2CT3OXZP3ZNDSJBAVCNFSM6AAAAAA5AHOXRSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZYHA2DSMZRHE . You are receiving this because you commented.Message ID: @.***>
Hi everyone, if you are still having issues, please contact support@onesignal.com and reference this github ticket and include your OneSignal App ID and the External ID with this issue.
Ask for Jon, I can assist in looking into it with you.
Same problem here with v5!
+1
ios has this problem too
ios也有这个问题
"react-native-onesignal": "^5.2.2",
any solution yet?
Hi everyone, this issue should be resolved if you upgrade to our latest SDK. Unfortunately when this issue was first created the SDK had some issues... but now it is much more stable.
Again, if you are still having issues after updating to the latest version of the SDK, please get a log while reproducing the issue following this guide: https://documentation.onesignal.com/docs/capturing-a-debug-log
Then share it with our Support team at support@onesignal.com
We would be happy to take a look and assist you directly.
https://github.com/OneSignal/react-native-onesignal/issues/1565#issuecomment-2263591100
jfishman1
Upgrading to latest version fixed this issue for me
Please see @jfishman1's notes above.
Since the logs shared with us are now outdated, I am closing this issue. Please open a new issue with clear details, or reach out to our Support team at support@onesignal.com.
What happened?
I'm using the new method
OneSignal.login(externalId)
in"react-native-onesignal": "5.0.0"
and docs saysso, for ios, it is working fine, but for Android, it is not.
Steps to reproduce?
What did you expect to happen?
Tags are correctly setup, but
externalId
is not created or linked after using the login method.I will attach an image where the external Id is not present, even after login. also, in log cat for android, i can confirm I'm sending the externalId.
React Native OneSignal SDK version
5.0.0
Which platform(s) are affected?
Relevant log output
Code of Conduct