Flutter plugin for Schibsted Account SDK
Disclaimer: This project is not maintained by Schibsted Account team. It is an independent initiative. Please report any issue or ideas directly into this repository. Pull requests are also welcome.
If you want to run the Android example project - please provide values in
example/android/app/src/main/assets/schibsted_account.conf
file.
For more info visit the SDK Setup doc.
If you want to run the iOS example project - please provide values in
example/ios/Runner/SchibstedAccountConfig.plist
file.
For more info visit the SDK Setup doc.
-
Configure your Android project following the steps in account-sdk-android docs
-
Change the Application theme (Flutter creates a AndroidManifest.xml that applies a theme to the Activity, not the Application). To do that, remove the
android:theme="@style/LaunchTheme"
from the<activity>
tag and add it to the<application>
tag. Then change the parent of@style/LaunchTheme
to@style/Theme.AppCompat.Light.NoActionBar
or some otherAppCompat
theme. -
Add a file with to
/res/values
that has the following information:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="schacc_conf_client_name">example client</string>
<string name="schacc_conf_redirect_scheme">example-scheme</string>
<string name="schacc_conf_redirect_host">://login</string>
</resources>
- Configure your iOS project following the steps in account-sdk-ios docs
- Add to project file SchibstedAccountConfig.plist that has the following information:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>environment</key>
<string>preproduction</string>
<key>clientID</key>
<string><client-id></string>
<key>clientSecret</key>
<string><client-secret></string>
<key>appURLScheme</key>
<string><url-schema></string>
</dict>
</plist>
Import the classes with:
import 'package:schibsted_account_sdk/schibsted_account.dart';
To start the login flow, just call:
SchibstedAccountPlugin.login;
To log out, just call:
SchibstedAccountPlugin.logout;
You can listen to the exposed SchibstedAccountPlugin.loginEvents
Stream to get the SchibstedAccountEvent
login events which contain the current state. State can be a value from the SchibstedAccountState
enum:
logged_out
- user has logged outlogged_in
- user has logged in and we have the User Data (email, displayName, ...)unknown
- should never happen. Would be sent if AndroidresultCode
was unknown and not handeled by the plugin.canceled
- user cancels the Login flow.fetching
- user has logged in and we start to fetch the User Data (email, displayName, ...)error
- when the SDK fails at some point
For more reference on how to use the plugin check the example
project in this repo.
- [✖] Implement iOS
- Write tests