diff --git a/CHANGELOG.md b/CHANGELOG.md index 2357e06..bd494cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Upgraded `flutter_web_auth_2` to 5.1.0 and aligned the Android callback Activity configuration with its updated authentication flow + +### Fixed +- Android authentication now closes the browser and returns the example app to the foreground after MiAuth or OAuth authorization +- Android release builds of the example app now declare the `INTERNET` permission required for authentication requests +- Corrected the Android callback Activity class name and consolidated the English and Japanese setup guidance around the canonical example Manifest + ### Removed - Unused private `MisskeyServerInfo` model (`lib/src/models/misskey_server_info.dart`) diff --git a/README.md b/README.md index c192e01..70b626d 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,10 @@ Add to `ios/Runner/Info.plist`: Add to `android/app/src/main/AndroidManifest.xml`: ```xml - + @@ -163,9 +166,16 @@ Add to `android/app/src/main/AndroidManifest.xml`: ``` +A complete, copyable configuration is available in +[`example/android/app/src/main/AndroidManifest.xml`](example/android/app/src/main/AndroidManifest.xml). +Treat that sample Manifest as the canonical working example for Android. + Notes: + - The `android:label` attribute on the `` is optional. You can omit it or set any string. - On Android 12+ (API level 31+), any Activity with an `intent-filter` must declare `android:exported="true"`. +- Set `android:taskAffinity=""` on both the exported `MainActivity` and `CallbackActivity` so the browser closes and the app returns to the foreground after authentication. +- Apps that perform network requests must declare `` directly under the `` element in `android/app/src/main/AndroidManifest.xml`. A declaration in `debug` or `profile` does not apply to release builds. - Use the same callback scheme string on both platforms: iOS (`CFBundleURLSchemes`) and Android (``). They must match exactly. Important (OAuth redirect on Android): @@ -260,22 +270,11 @@ final current = await auth.currentToken(); ``` ##### How to Support Both Methods in the Same App + - By registering the same `scheme` (e.g., `yourscheme`) in iOS's `Info.plist` and Android's `AndroidManifest.xml`, it can be shared between OAuth and MiAuth. - This library uses a scheme-only callback for MiAuth (e.g., `yourscheme://`). You do not need to reuse a path like `yourscheme://oauth/callback` for MiAuth. -- For Android, matching only on the `scheme` is sufficient as shown below (the `host` and `path` are optional). - -```xml - - - - - - - - - - -``` +- For Android, use the scheme-only configuration in [Android Configuration](#android-configuration). + The `host` and `path` restrictions remain optional; the complete sample Manifest is linked from that section. ### API Reference @@ -548,19 +547,32 @@ await auth.signOutAll(); `android/app/src/main/AndroidManifest.xml`に追加: ```xml - - + + + + + ``` +動作する完全な設定例は +[`example/android/app/src/main/AndroidManifest.xml`](example/android/app/src/main/AndroidManifest.xml)です。 +このサンプルManifestを、利用者がコピーできるAndroid設定の正しい実例として扱います。 + 補足: + - `` の `android:label` は省略可能です(省略しても動作します)。 - Android 12+(API 31 以降)では、`intent-filter` を持つ Activity に `android:exported="true"` の指定が必須です。 +- 認証後にブラウザを閉じてアプリを前面へ戻すため、exportedな`MainActivity`と`CallbackActivity`の両方に`android:taskAffinity=""`を設定してください。 +- ネットワーク通信を行うアプリでは、`android/app/src/main/AndroidManifest.xml`の``直下に``を宣言してください。`debug`または`profile`側だけの宣言はreleaseビルドへ適用されません。 - iOS(`CFBundleURLSchemes`)と Android(``)で登録するカスタムスキーム名は同一にしてください(完全一致が必要)。 #### MiAuth と OAuth の設定の違い(アプリ組み込み時のポイント) @@ -647,20 +659,8 @@ final current = await auth.currentToken(); - iOSの`Info.plist`・Androidの`AndroidManifest.xml`で同じ`scheme`(例: `yourscheme`)を1つ登録すれば、OAuth/MiAuthで共用可能です。 - 本ライブラリの MiAuth は scheme のみ(`yourscheme://`)を callback に使います。`yourscheme://oauth/callback` のようなパス付きに揃える必要はありません。 -- Androidは以下のように`scheme`のみのマッチで十分です(`host`や`path`は任意)。 - -```xml - - - - - - - - - - -``` +- Androidは[Android設定](#android設定)にある`scheme`のみの構成を使用してください。 + `host`や`path`による制限は任意で、完全なサンプルManifestは同セクションから参照できます。 ### API リファレンス @@ -788,4 +788,4 @@ class AccountEntry { - [Misskey OAuth ドキュメント](https://misskey-hub.net/ja/docs/for-developers/api/token/oauth/) - [Misskey MiAuth ドキュメント](https://misskey-hub.net/ja/docs/for-developers/api/token/miauth/) -- [pub.dev パッケージ](https://pub.dev/packages/misskey_auth) \ No newline at end of file +- [pub.dev パッケージ](https://pub.dev/packages/misskey_auth) diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 3670012..a7ec45d 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,6 @@ + + - + diff --git a/pubspec.yaml b/pubspec.yaml index 9dc10cf..82a9df7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: cupertino_icons: ^1.0.8 dio: ^5.9.0 flutter_secure_storage: ^9.0.0 - flutter_web_auth_2: ^4.0.0 + flutter_web_auth_2: ^5.1.0 crypto: ^3.0.3 dev_dependencies: