I am not fully understand you problem about firebase token.
In my system, I store both user identifier and firebase token of each device into database. Something, like this below...
[id], [userid], [appleUserId], [firebaseToken]
0001, xxxxx, 000625.9cc9a4be8d0c4axxxxxxxxxxxxxxxxxx.xxxx, c9ujMuHrc0f3keNzd1x1ae:APA91bHp......
0002, yyyyy, 001429.9ca6469bfab94xyyyyyyyyyyyyyyyyyy.yyyy, eUiInpEyekdlr10GWshvHu:APA91bHV......
So, after transferred the app, I just need to migrate only appleUserId.
The documentation of how to generate transfer identifiers it is also quite confusing as it is not clear if you need to generate a transfer identifier for all users and what to do if the user does not login into the app in the 60 day period that they mention after the transfer.
I am total agreed with you that it is quite confusing.
Anyway, this is step to migrate appleUserId.
- Obtain access token to migrate user id (for sender)
- Generate transfer identifier (using sender access token)
- Obtain access token to migrate user id (for recipient)
- Find new user id by transfer identifier (using recipient access token)
Due to there are only 1000 users who sign in with apple to my system.
I create a bash script that call API to convert the user id one by one.
Here is my script to retrieving "transfer identifier".
#!/bin/bash
generateTransferIdFunc() {
APIURL="https://appleid.apple.com/auth/usermigrationinfo"
recipientTeamId=7253******
senderAppBundleID=com.test.app
senderSecret=eyJraWQiOiJBQTQ4NkJaWTUyIiw.........
if [ $# -eq 1 ] && [ -f $1 ]
then
OLDIFS=$IFS
IFS=","
while read oid userid email
do
echo "Start retrieving trasfer_sub for : $userid, $email"
curl -sS --location --request POST $APIURL \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer ae42b9xxxxxxxxxxxxxxxxxxxxxxxxxxx.0.xxxxx.4xxxxxxxxxxxxxxxxxxxxx' \
-d "sub=$userid&target=$recipientTeamId&client_id=$senderAppBundleID&client_secret=$senderSecret"
echo ""
echo "End."
done < $1
IFS=$OLDIFS
else
echo "Input file not found!"
fi
}
if [ $# -eq 1 ] && [ -f $1 ]
then
generateTransferIdFunc $1 | while IFS= read -r line; do printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S.%N')" "$line"; done | tee -a generateTransferId.log
else
echo "Input file not found!"
fi
Note: senderSecret is generated by JWT.
Please see https://medium.com/identity-beyond-borders/how-to-configure-sign-in-with-apple-77c61e336003
You can run the script by
sh generate_transfer_identifier.sh input.csv
Here is sample input.csv
oid,appleId,email
129914891,001870.1ffcf5**************************.0729,a********@privaterelay.appleid.com
129985693,001559.8322cd**************************.0728,b********@privaterelay.appleid.com
Then you will receive "transfer identifier" for each user.
After that you can use the "transfer identifier" for retrieving new user id that is used with Recipient Team.
Please read this article for convert "transfer identifier" to the new user id.
https://developer.apple.com/documentation/sign_in_with_apple/bringing_new_apps_and_users_into_your_team
Note: You can modify the above script to call an API to convert it.
Finally, you will receive the new user id. Then you just need to update the user id into your database.
I hope the above information is useful to you.