问题描述
作为购买应用程序的一部分,我们正在将应用程序从一个Apple开发人员帐户转移到另一个帐户。该应用程序使用Apple登录和Firebase身份验证,似乎需要完成一些步骤才能为使用Apple登录进行注册的用户生成传输标识符。
但是,由于我们将Firebase用作应用程序的后端,因此我们无法直接控制身份验证过程和Apple登录生成的用户ID,以及它们如何存储在Firebase Auth中以及如何在应用程序后更新它们转移。
关于如何生成转移标识符的文档也非常混乱,因为尚不清楚您是否需要为所有用户生成转移标识符,以及如果用户在60天的时间内未登录应用程序该怎么办他们在转移后提到的。
如果有人遇到过这个问题,我们将非常感谢您提供一些有关如何实现此目标的建议。非常感谢!
解决方法
我不完全了解您有关Firebase令牌的问题。
在我的系统中,我将每个设备的用户标识符和firebase令牌都存储到数据库中。像这样的东西...
[id],[userid],[appleUserId],[firebaseToken]
0001,xxxxx,000625.9cc9a4be8d0c4axxxxxxxxxxxxxxxxxx.xxxx,c9ujMuHrc0f3keNzd1x1ae:APA91bHp......
0002,yyyyy,001429.9ca6469bfab94xyyyyyyyyyyyyyyyyyy.yyyy,eUiInpEyekdlr10GWshvHu:APA91bHV......
因此,在转移应用程序之后,我只需要迁移appleUserId。
关于如何生成转移标识符的文档也非常混乱,因为尚不清楚您是否需要为所有用户生成转移标识符,以及如果用户在60天的时间内未登录应用程序该怎么办他们在转移后提到的。
我完全同意您的看法,这很令人困惑。
无论如何,这是迁移appleUserId的步骤。
- 获取访问令牌以迁移用户ID(用于发件人)
- 生成传输标识符(使用发件人访问令牌)
- 获取访问令牌以迁移用户ID(针对收件人)
- 通过传输标识符(使用收件人访问令牌)查找新的用户ID
由于只有1000位用户使用Apple登录到我的系统。 我创建了一个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
这是示例输入。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更新到数据库中即可。
我希望以上信息对您有用。