我不是很理解你关于Firebase令牌的问题。
在我的系统中,我将每个设备的用户标识符和Firebase令牌存储到数据库中。就像下面这样...
[id], [userid], [appleUserId], [firebaseToken]
0001, xxxxx, 000625.9cc9a4be8d0c4axxxxxxxxxxxxxxxxxx.xxxx, c9ujMuHrc0f3keNzd1x1ae:APA91bHp......
0002, yyyyy, 001429.9ca6469bfab94xyyyyyyyyyyyyyyyyyy.yyyy, eUiInpEyekdlr10GWshvHu:APA91bHV......
所以,转移应用程序后,我只需要迁移appleUserId。
生成传输标识符的文档也非常令人困惑,因为不清楚是否需要为所有用户生成传输标识符,以及如果用户在转移后60天内没有登录该应用程序该怎么办。
我完全同意您的看法,这确实很令人困惑。
无论如何,这是迁移appleUserId的步骤:
1. 获取迁移用户ID的访问令牌(对于发送者)
2. 生成传输标识符(使用发送者访问令牌)
3. 获取迁移用户ID的访问令牌(对于接收者)
4. 使用接收者访问令牌通过传输标识符查找新的用户ID
由于只有1000个用户使用苹果登录我的系统,我创建了一个Bash脚本来调用API逐个转换用户ID。
以下是我检索“传输标识符”的脚本。
#!/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
注意:senderSecret 是由 JWT 生成的。
请参见
https://medium.com/identity-beyond-borders/how-to-configure-sign-in-with-apple-77c61e336003
您可以通过运行脚本来实现。
sh generate_transfer_identifier.sh input.csv
这里是样本 input.csv
oid,appleId,email
129914891,001870.1ffcf5**************************.0729,a********@privaterelay.appleid.com
129985693,001559.8322cd**************************.0728,b********@privaterelay.appleid.com
然后,您将收到每个用户的“转移标识符”。
之后,您可以使用“转移标识符”来检索与接收方团队一起使用的新用户ID。请阅读此文章以将“转移标识符”转换为新用户ID。
https://developer.apple.com/documentation/sign_in_with_apple/bringing_new_apps_and_users_into_your_team
注意:您可以修改上述脚本以调用API进行转换。
最后,您将收到新的用户ID。然后,您只需要将用户ID更新到您的数据库中。
希望以上信息对您有用。