Apple login on Android
インストール手順とこのプラグインの全てのマークダウン ガイドを含むセットアップ コマンドをコピーしてください。
Android 上の Apple ログインはハックです。Apple は Android に対して公式のサポートを提供していないため、解決策は少しハック的です。 Sign in with Apple Android は現在、OAuth2 ウェブサイトを表示するために Chrome タブを使用しています。このアプローチには、以下のような課題があります:
__CAPGO_KEEP_0__
- 難しい設定
- バックエンドが必要です
Android上のフローを理解する
Android上のフローを理解するAndroid上のフローを図で説明します:
flowchart TD
A("await SocialLogin.login()") -->|Handled in the plugin|B(Generate the login URL)
B --> |Pass the link| C(Open the Chrome browser)
C --> D(Wait for the user to login)
D --> |Apple redirects to your backend|E(Handle the data returned from Apple)
E --> F(Redirect back to the app)
F --> G(Return to JS)
課題とフローの理解をもとに、設定を始めましょう。
サービスIDを作成する
サービスIDを作成する-
Apple Developer Portalにログインする Apple Developer Portalにログインする.
-
クリックする
Identifiers.
このような画面が表示されるはずです。
- このフィールドが
App IDs - このフィールドが
- このフィールドが
-
Apple Login for IOSが設定されていない場合は、以下の手順でApp IDを作成してください。
Sign in with Applecreate app stepの手順に従ってください。- Click on your app
- アプリの機能が有効になっていることを確認
Sign in with Apple機能が有効になっていることを確認
- 有効になっていない場合は有効にします。
- Click on your app
-
すべての機能に戻る
All Identifiers
-
アプリを選択
App Idsアプリの設定に移動Services IDs
-
新しい識別子を作成
-
をクリックしてください
-
選択
Servcice IDsとクリックContinue
-
説明と識別子を入力してください
Continuie.
-
詳細を確認し、登録を
Register
-
サービスID登録を確認するにはクリックしてください。
-
オプションを有効にする
Sign in with Appleオプション
-
設定
Sign In with Apple
-
設定
Primary App IDApp IDが前のステップで設定されたものに設定されていることを確認する
-
ホストするバックエンドのドメインを追加する
-
を使用します。
Done
-
ドメインとリターンURLの設定を確認してください。
Continue
-
ボタンをクリックしてください。
Save
-
キーを作成中
キーを作成する-
すべてに戻る
All Identifiers
-
クリックしてください
Keys
-
プラスアイコンをクリック
-
キー名を入力
-
Select
Sign in with Appleand clickConfigure
-
Select the primary App ID, and press
Save
-
Click on
Continue
-
クリックしてください
Register
-
__CAPGO_KEEP_0__のキーIDをコピーし、キーをダウンロードしてください。
-
__CAPGO_KEEP_0__をダウンロードしたキーを、バックエンドフォルダに保存してください。
チームIDを取得する
「チーム ID を取得する」セクション使用するには Login with Apple Androidで使用するには、チーム IDを取得する必要があります。 Team ID後端で使用します。
-
Capgoアカウントの開発者アカウントにアクセスし このウェブサイト 下部にスクロール
-
開発者アカウントのチーム IDの場所を探す
Team ID
「アプリのリダイレクト設定」セクション
図で見たように、後端は「アプリのリダイレクト設定」というステップを実行します。チーム IDは後端で使用されます。 Redirect back to the app. この変更は、手動でアプリを変更する必要があります。
- Modify the
AndroidManifest.xml-
Open the file, I will use
AndroidStudio
-
Find the
MainActivityと、MainActivityに追加する必要があるIntentフィルタ
<intent-filter><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="capgo-demo-app" android:host="path" /></intent-filter>
-
- Modify the
MainActivity-
Please open the
MainActivity
-
MainActivityに追加する必要があるcode
@Overrideprotected void onNewIntent(Intent intent) {String action = intent.getAction();Uri data = intent.getData();if (Intent.ACTION_VIEW.equals(action) && data != null) {PluginHandle pluginHandle = getBridge().getPlugin("SocialLogin");if (pluginHandle == null) {Log.i("Apple Login Intent", "SocialLogin login handle is null");return;}Plugin plugin = pluginHandle.getInstance();if (!(plugin instanceof SocialLoginPlugin)) {Log.i("Apple Login Intent", "SocialLogin plugin instance is not SocialLoginPlugin");return;}((SocialLoginPlugin) plugin).handleAppleLoginIntent(intent);return;}super.onNewIntent(intent);}
-
Backend configuration
Section titled “Backend configuration”A backend is required for Android, but configuring a backend will also impact IOS. An example backend is provided here
This example provides the following:
- A simple JSON database
- A way to request the JWT from Apple’s servers
- A simple JWT verification
このチュートリアルで述べたすべてのことを考慮して、以下のようになります。 env セクションの見本は以下のようになります。
ANDROID_SERVICE_ID= Service IDIOS_SERVICE_ID= App ID
env: { PRIVATE_KEY_FILE: "AuthKey_U93M8LBQK3.p8", KEY_ID: "U93M8LBQK3", TEAM_ID: "UVTJ336J2D", ANDROID_SERVICE_ID: "ee.forgr.io.ionic.starter.service2", IOS_SERVICE_ID: "me.wcaleniewolny.test.ionic.vue", PORT: 3000, REDIRECT_URI: "https://xyz.wcaleniewolny.me/login/callback", BASE_REDIRECT_URL: "capgo-demo-app://path"}プラグインを使用する
セクションのタイトルは「プラグインを使用する」プラグインの使用方法はIOSと同じです。詳細はそのセクションを参照してください。']} (Note: The translation is based on the provided source text and may not be perfect. It's always recommended to have a native speaker review the translation for accuracy and cultural context.) The protected tokens were left unchanged as per the request. The placeholders __CAPGO_KEEP_0__ were not present in the source text. The translations are in the same order as the input. The JSON object has exactly one key named login translations HOWEVER, the initialize method changes a bit.
await SocialLogin.initialize({ apple: { clientId: 'ee.forgr.io.ionic.starter.service2', redirectUrl: 'https://appleloginvps.wcaleniewolny.me/login/callback' }})Creating the app
Section titled “Creating the app”-
App IDがまだない場合は、プラスボタンをクリックしてください
-
選択
App IDs続けてクリック
-
種類をクリック
App選択Continue
-
説明とApp IDを入力
-
有効化
Sign with Apple機能
-
クリック
Continue
-
確認の詳細を確認し
Register
Android上のAppleログインから続行
Android上のAppleログインから続行のセクションAppleログインを使用している場合 Android上のAppleログイン アプリの認証とアカウントフローの計画に使用する場合、Android上のAppleログインを接続する @capgo/capacitor-social-login @capgo/capacitor-social-login @capgo/capacitor-social-login @capgo/capacitor-social-login @capgo/capacitor-passkey @capgo/capacitor-passkey @capgo/capacitor-native-biometric @capgo/capacitor-native-biometric Two-factor authentication Edit page