Skip to content

Commit 891018b

Browse files
committed
Example application & documentation update.
1 parent 50a54a3 commit 891018b

File tree

11 files changed

+71
-77
lines changed

11 files changed

+71
-77
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
21
# 0.0.1
32
Inital release.
43

54
* Business APIs.
65
* Social login (View documentation for supported providers).
76
* Web Screen-Sets.
8-
* Interruption handling.
7+
* Interruption handling.
8+
9+
# 0.0.2
10+
Example & documentation.
11+
12+
* Example application updates.
13+
* Documentation updates.

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ A [Flutter](https://flutter.dev) plugin for interfacing Gigya's native SDKs into
66
Flutter plugin that provides an interface for the Gigya API.
77

88
## Developers Preview Status
9-
The plugin allows you to use the core elements & business API's flows available within the mobile SDKs.
10-
Session encryption & management is handled in each platform. This plugin is currently in an early **developers preview** stage.
9+
The plugin allows you to use the core elements & business API flows available within the SAP Customer Data Cloud mobile SDKs.
10+
This plugin is currently in an early developers preview stage.
1111

1212
## Setup & Gigya core integration
1313

1414
### Android setup
1515

16-
Please add the following to your native implementation.
16+
Add the following to your native implementation.
1717

1818
```kotlin
1919
class MainActivity : FlutterActivity() {
@@ -69,14 +69,14 @@ GigyaSdk.instance.send('REQUEST-ENDPOINT', {PARAMETER-MAP}).then((result) {
6969
debugPrint(error.errorDetails);
7070
});
7171
```
72-
Example implementation is demostrated in the *send_request.dart* class of the provided example applicaiton.
72+
Example implementation is demonstrated in the *send_request.dart* class of the provided example application.
7373

7474
## Business APIs
7575

76-
The plugin provides API to varius business APIs which iclude:
76+
The plugin provides an interface to these core SDK business APIs:
7777
**login, register, getAccount, getAccount, isLoggedIn ,logOut, addConnection, removeConnection**
7878
Implement them using the same request structure as shown above.
79-
Example application includes the varius implementations.
79+
Example application includes the various implementations.
8080

8181
## Social login
8282

@@ -86,21 +86,21 @@ The Flutter plugin supports the same *providers supported by the Core Gigya SDK.
8686
Supported social login providers:
8787
google, facebook, line, wechat, apple, amazon, linkedin, yahoo.
8888

89-
## Embeded socail providers
89+
## Embedded social providers
9090

91-
Specific social providers (Facebook, Google) require addional setup. This due to the their
91+
Specific social providers (Facebook, Google) require additional setup. This due to the their
9292
requirement for specific (embedded) SDKs.
9393
```
9494
Example for both Facebook & Google are implemented in the example application.
9595
```
9696

9797
### Facebook
9898

99-
Follow the core SDK documentation and instructions for setting Facbook login.
99+
Follow the core SDK documentation and instructions for setting Facebook login.
100100
[Android documentation](https://sap.github.io/gigya-android-sdk/sdk-core/#facebook)
101101
[iOS documentation](https://sap.github.io/gigya-android-sdk/sdk-core/#facebook)
102102

103-
iOS: In additon add the following to your Runner's *AppDelegate.swift* file:
103+
iOS: In addition add the following to your Runner's *AppDelegate.swift* file:
104104
```swift
105105
Gigya.sharedInstance(UserHost.self).registerSocialProvider(of: .facebook, wrapper: FacebookWrapper())
106106
```
@@ -112,11 +112,11 @@ the [flutter_facebook_login] plugin to your **pubspec.yaml** dependencies.
112112

113113
### Google
114114

115-
Follow the core SDK documentation and instructions for setting Facbook login.
115+
Follow the core SDK documentation and instructions for setting Google login.
116116
[Android documentation](https://sap.github.io/gigya-android-sdk/sdk-core/#google)
117117
[iOS documentation](https://sap.github.io/gigya-swift-sdk/GigyaSwift/#google)
118118

119-
iOS: In additon add the following to your Runner's *AppDelegate.swift* file:
119+
iOS: In addition add the following to your Runner's *AppDelegate.swift* file:
120120
```swift
121121
Gigya.sharedInstance(UserHost.self).registerSocialProvider(of: .google, wrapper: GoogleWrapper())
122122
```
@@ -172,7 +172,7 @@ GigyaSdk.instance.login(loginId, password).then((result) {
172172
final response = Account.fromJson(result);
173173
// Successfully logged in
174174
}).catchError((error) {
175-
// Interruption may occured.
175+
// Interruption may have occurred.
176176
if (error.getInterruption() == Interruption.conflictingAccounts) {
177177
// Reference the correct resolver
178178
LinkAccountResolver resolver = GigyaSdk.instance.resolverFactory.getResolver(error);
@@ -187,7 +187,7 @@ GigyaSdk.instance.login(loginId, password).then((result) {
187187
Once you reference your resolver, create your relevant UI to determine if a site or social linking is
188188
required (see example app for details) and use the relevant "resolve" method.
189189

190-
Example of resolveing link to site when trying to link a new social account to a site account.
190+
Example of resolving link to site when trying to link a new social account to a site account.
191191
```
192192
final String password = _linkPasswordController.text.trim();
193193
resolver.linkToSite(loginId, password).then((res) {

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.sap.gigya_flutter_plugin'
2-
version '0.0.1'
2+
version '0.0.2'
33

44
buildscript {
55
ext.kotlin_version = '1.3.50'

example/lib/main.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@ class _MyAppState extends State<MyApp> {
2020
Widget build(BuildContext context) {
2121
return MaterialApp(
2222
initialRoute: '/',
23-
routes: {
24-
// When navigating to the "/" route, build the FirstScreen widget.
25-
'/': (context) => HomePageWidget(),
26-
// When navigating to the "/second" route, build the SecondScreen widget.
27-
'/send_request': (context) => SendRequestPageWidget(),
28-
'/login_credentials': (context) => LoginWidthCredentialsWidget(),
29-
'/register_email': (context) => RegisterWithEmailWidget(),
30-
'/account_information': (context) => AccountInformationWidget(),
31-
'/manage_connections': (context) => ManageConnectionWidget(),
32-
},
23+
routes: _exampleRoutes(),
3324
);
3425
}
26+
27+
/// Each route demonstrates a different flow.
28+
///
29+
/// Specific implementation available in every route widget.
30+
Map<String, WidgetBuilder> _exampleRoutes() {
31+
return {
32+
'/': (context) => HomePageWidget(),
33+
'/send_request': (context) => SendRequestPageWidget(),
34+
'/login_credentials': (context) => LoginWidthCredentialsWidget(),
35+
'/register_email': (context) => RegisterWithEmailWidget(),
36+
'/account_information': (context) => AccountInformationWidget(),
37+
'/manage_connections': (context) => ManageConnectionWidget(),
38+
};
39+
}
3540
}

example/lib/routes/account_information.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ class _AccountInformationWidgetState extends State<AccountInformationWidget> {
3030
builder: (context, snapshot) {
3131
if (snapshot.hasData) {
3232
Account account = snapshot.data;
33-
_firstNameTextController.text = _firstNameTextController.text.isEmpty
34-
? account.profile.firstName : _firstNameTextController.text.trim() ?? '';
33+
_firstNameTextController.text =
34+
_firstNameTextController.text.isEmpty ? account.profile.firstName : _firstNameTextController.text.trim() ?? '';
3535
return Container(
3636
child: Column(
3737
children: [
3838
_inProgress
3939
? LinearProgressIndicator(
40-
minHeight: 4,
41-
)
40+
minHeight: 4,
41+
)
4242
: SizedBox(
43-
height: 4,
44-
),
43+
height: 4,
44+
),
4545
Padding(
4646
padding: const EdgeInsets.all(16.0),
4747
child: Column(
@@ -123,19 +123,23 @@ class _AccountInformationWidgetState extends State<AccountInformationWidget> {
123123
);
124124
}
125125

126+
/// Fetch account information.
126127
Future<Account> _getAccountInformation() async {
127128
var result = await GigyaSdk.instance.getAccount();
128129
debugPrint(jsonEncode(result));
129130
Account response = Account.fromJson(result);
130131
return response;
131132
}
132133

134+
/// Update account information given new updated [account] object.
133135
_updateAccountInformation(Account account) async {
134136
setState(() {
135137
_inProgress = true;
136138
});
137139
String newFirstName = _firstNameTextController.text.trim();
138-
var result = await GigyaSdk.instance.setAccount({'profile' : jsonEncode({ 'firstName': newFirstName})});
140+
var result = await GigyaSdk.instance.setAccount({
141+
'profile': jsonEncode({'firstName': newFirstName})
142+
});
139143
debugPrint(jsonEncode(result));
140144
FocusScope.of(context).unfocus();
141145
setState(() {

example/lib/routes/manage_connection.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class ManageConnectionWidget extends StatefulWidget {
1010
}
1111

1212
class _ManageConnectionWidgetState extends State<ManageConnectionWidget> {
13-
1413
@override
1514
Widget build(BuildContext context) {
1615
return Scaffold(
@@ -78,12 +77,18 @@ class _ManageConnectionWidgetState extends State<ManageConnectionWidget> {
7877
return response;
7978
}
8079

80+
/// Add a social connection.
81+
///
82+
/// In this case adding Facebook social connection.
8183
void _addConnection() async {
8284
var result = await GigyaSdk.instance.addConnection(SocialProvider.facebook);
8385
debugPrint(jsonEncode(result));
8486
setState(() {});
8587
}
8688

89+
/// Remove a social connection.
90+
///
91+
/// In this case removing Facebook connection.
8792
void _removeConnection() async {
8893
await GigyaSdk.instance.removeConnection(SocialProvider.facebook);
8994
setState(() {});

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ packages:
8585
path: ".."
8686
relative: true
8787
source: path
88-
version: "0.0.1"
88+
version: "0.0.2"
8989
google_sign_in:
9090
dependency: "direct main"
9191
description:

ios/Classes/GigyaSdkWrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
1818

1919
init(accountSchema: T.Type) {
2020
// Initializing the Gigya SDK instance.
21-
GigyaDefinitions.versionPrefix = "flutter_0.0.1_"
21+
GigyaDefinitions.versionPrefix = "flutter_0.0.2_"
2222
sdk = Gigya.sharedInstance(accountSchema)
2323
}
2424

lib/interruption/interruption_resolver.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/services.dart';
22
import 'package:gigya_flutter_plugin/gigya_flutter_plugin.dart';
33
import 'package:gigya_flutter_plugin/models/gigya_models.dart';
44

5+
/// Determines the relevant interruption resolver according to given error.
56
class ResolverFactory {
67
final MethodChannel _channel;
78

@@ -21,18 +22,21 @@ class ResolverFactory {
2122
}
2223
}
2324

25+
/// Resolver used for link account flow interruption.
2426
class LinkAccountResolver with DataMixin {
2527
final MethodChannel _channel;
2628

2729
LinkAccountResolver(this._channel) {
2830
getConflictingAccounts();
2931
}
3032

33+
/// Get the user conflicting account object to determine how to resolve the flow.
3134
Future<ConflictingAccounts> getConflictingAccounts() async {
32-
Map<String, dynamic> map = await _channel.invokeMapMethod<String, dynamic>('getConflictingAccounts');
35+
Map<String, dynamic> map = await _channel.invokeMapMethod<String, dynamic>('getConflictingAccounts');
3336
return ConflictingAccounts.fromJson(map);
3437
}
3538

39+
/// Link social account to existing site account.
3640
Future<Map<String, dynamic>> linkToSite(String loginId, String password) async {
3741
final Map<String, dynamic> res = await _channel.invokeMapMethod<String, dynamic>('linkToSite', {
3842
'loginId': loginId,
@@ -43,6 +47,7 @@ class LinkAccountResolver with DataMixin {
4347
return res;
4448
}
4549

50+
/// Link site account to existing social account.
4651
Future<Map<String, dynamic>> linkToSocial(SocialProvider provider) async {
4752
final Map<String, dynamic> res = await _channel.invokeMapMethod<String, dynamic>('linkToSocial', {
4853
'provider': provider.name,
@@ -53,11 +58,13 @@ class LinkAccountResolver with DataMixin {
5358
}
5459
}
5560

61+
/// Resolver used for pending registration interruption.
5662
class PendingRegistrationResolver with DataMixin {
5763
final MethodChannel _channel;
5864

5965
PendingRegistrationResolver(this._channel);
6066

67+
/// Set the missing account data in order to resolve the interruption.
6168
Future<Map<String, dynamic>> setAccount(Map<String, dynamic> map) async {
6269
final Map<String, dynamic> res = await _channel.invokeMapMethod<String, dynamic>('resolveSetAccount', {
6370
map,
@@ -68,6 +75,9 @@ class PendingRegistrationResolver with DataMixin {
6875
}
6976
}
7077

78+
/// Resolver used for pending verification interruption.
79+
///
80+
/// Use available [regToken] value to resolve.
7181
class PendingVerificationResolver {
7282
final String _regToken;
7383

lib/models/gigya_models.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:convert';
22

3+
/// Available interruptions.
34
enum Interruption {
45
pendingRegistration,
56
pendingVerification,
@@ -813,8 +814,8 @@ class Work {
813814
}
814815
}
815816

817+
/// Conflicting accounts model used for resolving a link account interruption flow.
816818
class ConflictingAccounts {
817-
818819
String loginID;
819820
List<String> loginProviders;
820821

0 commit comments

Comments
 (0)