ABOUT YOU Dart & Flutter Packages

repository·master·Indexed 42 days ago

https://github.com/aboutyou/dart_packages

A collection of Dart and Flutter plugins maintained by ABOUT YOU, featuring state management, authentication, and operation queuing. Key packages include sign_in_with_apple (supporting iOS, macOS, Android, and Web), pending_operations, state_queue, and with_bloc.

Tokens
9.3K
Snippets
32
Records
46
Agent score
53%

What's inside ABOUT YOU Dart Packages

  1. Overview of sign_in_with_apple_platform_interface

    master
    The sign_in_with_apple_platform_interface package provides a common platform interface for the sign_in_with_apple plugin. It is designed to ensure that both the main plugin and its various platform-specific implementations (such as iOS or Android) adhere to the same API contract, enabling consistent behavior across different platforms.
  2. Understand the Sign in with Apple integration flow

    master

    Integrating Sign in with Apple requires a full-stack approach. The plugin handles the client-side interaction, but you must implement server-side verification to ensure security.

    The complete flow is:

    1. Client-side: The Flutter app uses the plugin to request credentials from Apple.
    2. Credential Receipt: The plugin receives credentials (like an authorization code).
    3. Server-side Verification: Your backend must send these credentials to Apple's servers to verify they are valid and belong to the intended user.
    4. Session Management: Once verified, your server derives a new session for the user. Your server should use a refresh token to verify the session with Apple daily and revoke the session if the user withdraws authorization on Apple's side.
  3. Configure local domain and Redirect URL for Sign in with Apple

    master

    To test the web plugin locally, you must use a valid domain that is registered with your Sign in with Apple service in the Apple Developer portal.

    1. Local Mapping: Add the domain to your /etc/hosts file (e.g., 127.0.0.1 siwa-flutter-plugin.dev).
    2. Apple Portal: Register this domain as both a Domain and a Redirect URL in the development portal.
    3. Glitch Example: If using the Glitch example server, ensure the redirect URL parameter is set to your local HTTPS domain (e.g., https://siwa-flutter-plugin.dev/).
  4. Configure Web support for Sign in with Apple

    master

    Script Import

    Add this script to the <head> tag of your index.html:

    <script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>

    Apple Developer Portal Configuration

    In your Service ID settings:

    • Domains and Subdomains: Add the domain hosting your web app.
    • Return URLs: Add the URL where Apple will post the final credentials. If this is omitted, the authentication flow will hang at the last step.
  5. Test Android deep links for sign_in_with_apple

    master

    You can test Android deep link handling using adb. This is useful for simulating the callback from the Sign In with Apple (SiwA) process or testing general deep link navigation within the app.

    Simulate a SiwA callback

    Use this command to mimic the intent:// link that a successful redirect would use:

    adb shell am start -a android.intent.action.VIEW \
        -c android.intent.category.BROWSABLE \
        -d "signinwithapple://callback?code=abc123" com.aboutyou.dart_packages.sign_in_with_apple_example

    Use this command to test deep link entry into the app. Note that this will close the Chrome Custom Tab if a SiwA login flow is currently active:

    adb shell am start -a android.intent.action.VIEW \
        -c android.intent.category.BROWSABLE \
        -d "siwa-example://siwa.example.com/foo" com.aboutyou.dart_packages.sign_in_with_apple_example
  6. Configure Android support for Sign in with Apple

    master

    Requirements

    • Android V2 Embedding: Ensure your project uses the Android V2 embedding by checking AndroidManifest.xml for:
      <meta-data
        android:name="flutterEmbedding"
        android:value="2" 
      />
    • Launch Mode: To ensure deep links from the Chrome Custom Tab return to your app, set your launchMode to either singleTask or singleTop in your Android configuration.

    Android Manifest Setup

    Add the following activity to your android/app/src/main/AndroidManifest.xml inside the <application> tag to handle the callback:

    <activity
        android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
        android:exported="true"
    >
        <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="signinwithapple" />
            <data android:path="callback" />
        </intent-filter>
    </activity>

    Redirecting back to Android

    On your server, after processing the Apple callback, redirect the user back to your app using this intent URL format:

    intent://callback?${PARAMETERS_FROM_CALLBACK_BODY}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end
    • Replace ${PARAMETERS_FROM_CALLBACK_BODY} with the urlencoded body received from Apple.
    • Replace YOUR.PACKAGE.IDENTIFIER with your app's Play Store package ID.
  7. Set up sign_in_with_apple on macOS

    master

    To run the example on macOS, ensure you have cocoapods installed globally (Flutter requires a global installation to gather plugin information). You must also enable macOS desktop support in your Flutter configuration.

    1. Install CocoaPods via Homebrew if not already present.
    2. Enable macOS desktop support.
    3. Run the application on the macOS desktop target.
    brew install cocoapods
    flutter config --enable-macos-desktop
    flutter run -d macOS