flutter_signinwithapple 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

signinwithapple #

A new Flutter package to use platform-wide Apple-Sign-In!

It is only usable by Participants of the Apple Developer Program!

In the background it uses [flutter_web_auth][flutter_web_auth] for all devices except iOS devices with iOS 13 or higher, where it uses [apple_sign_in][apple_sign_in] to provide a native look. [flutter_web_auth]: https://pub.dev/packages/flutter_web_auth [apple_sign_in]: https://pub.dev/packages/apple_sign_in

Setup #

The setup works like the most other Flutter Plugins, but you need to add the custom URL-Schemes to iOS and Android:

Android #

In order to capture the callback url, the following activity needs to be added to your AndroidManifest.xml. Be sure to relpace YOUR_CALLBACK_URL_SCHEME_HERE with your actual callback url scheme.

<manifest>
  <application>

    <activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
      <intent-filter android:label="flutter_web_auth">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="YOUR_CALLBACK_URL_SCHEME_HERE" />
      </intent-filter>
    </activity>

  </application>
</manifest>

iOS #

In order to capture the callback url, the following part needs to be added to your Info.plist in the iOS-Folder. Be sure to replace YOUR_CALLBACK_URL_SCHEME_HERE with your actual callback url scheme.

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>YOUR_CALLBACK_URL_SCHEME_HERE</string>
		</array>
	</dict>
</array>

Usage #

You have to follow some steps first before using this Plugin:

Apple Developer Console #

First open your Runner.xcodeworkspace on your MacOS-Device, go to Runner and select the Runner-Target. Change your Bundle identifier to your own one, then choose Signin & Capabilities, where you need to select your Team, that is part of the Apple Developer Program. Recheck your Bundle Identifier, then add the Sign in with Apple Capability.

In your [Apple-Developer-Console][Apple-Developer-Console] go to your Certificates, IDs & Profiles, navigate to Keys and register a new Key with the Sign in with Apple capability. When you configure it, select the Primary-App-ID you previously set as you Bundle Identifier. [Apple-Developer-Console]: https://developer.apple.com/account/#/overview/

Now choose Identifiers in the left column, and add a new Service ID. Set your Description and Identifier (needs to be different from your Bundle Identifier). This identifier will be your clientID. After creation, open it up again and enable Sign in with Apple. If you want to use your own server to handle the redirect back to the app, you put your own domain and redirect ULR in (the url you will specify later in the app, that handles the redirect). If you don't want to use you own server, put fuf.me as the domain, and http://fuf.me:43823/ as the redirect url in, then save. You can't just put your URL-Scheme here, because Sign-In-With-Apple Redirect-URLs need to have the http / https Scheme.

In the code #

import 'package:flutter/material.dart';
import 'package:signinwithapple/signinwithapple.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sign in with Apple',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Sign in with Apple"),
        ),
        body: Center(
            child: FlatButton(
              onPressed: () async {
                print(await SignInWithApple().available);
                AppleUser t = await SignInWithApple().signIn(config: SignInWithAppleConfig(clientId: "your.client.id", urlSchemeRedirectUri: "your.redirect.url.scheme", useOwnRedirectServer: false));
                print(t.idToken);
                print(t.authCode);
              },
              child: Text("Sign in with apple..."),
            )
        ),
      )
    );
  }
}

One more thing... #

If you want to have a native-looking Button, check out flutter_signin_button.

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:signinwithapple/flutter_signinwithapple.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sign in with Apple',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Sign in with Apple"),
        ),
        body: Center(
            child: FlatButton(
              onPressed: () async {
                print(await SignInWithApple().available);
                AppleUser t = await SignInWithApple().signIn(config: SignInWithAppleConfig(clientId: "com.kedil.examplesignin", urlSchemeRedirectUri: "com.kedil.signin", useOwnRedirectServer: false));
                print(t.idToken);
                print(t.authCode);
              },
              child: Text("Sign in with apple..."),
            )
        ),
      )
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_signinwithapple: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_signinwithapple/flutter_signinwithapple.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
12
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
87
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:flutter_signinwithapple/flutter_signinwithapple.dart that imports:
  • package:flutter_web_auth/flutter_web_auth.dart that declares support for platforms: Android, iOS, macOS

Package does not support Flutter platform Web

Because:

  • package:flutter_signinwithapple/flutter_signinwithapple.dart that imports:
  • package:flutter_web_auth/flutter_web_auth.dart that declares support for platforms: Android, iOS, macOS

Package does not support Flutter platform Windows

Because:

  • package:flutter_signinwithapple/flutter_signinwithapple.dart that imports:
  • package:flutter_web_auth/flutter_web_auth.dart that declares support for platforms: Android, iOS, macOS

Package does not support Flutter platform macOS

Because:

  • package:flutter_signinwithapple/flutter_signinwithapple.dart that imports:
  • package:device_info/device_info.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • flutter_signinwithapple that is a package requiring null.

Health suggestions

Fix lib/flutter_signinwithapple.dart. (-1 points)

Analysis of lib/flutter_signinwithapple.dart reported 2 hints:

line 66 col 42: The exception variable 'e' isn't used, so the 'catch' clause can be removed.

line 139 col 29: This function has a return type of 'Future

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The package description is too short. (-3 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
apple_sign_in ^0.1.0 0.1.0
device_info ^0.4.2+2 0.4.2+4
flutter 0.0.0
flutter_web_auth ^0.2.3 0.2.4
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test