Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tal-mi committed Oct 4, 2021
2 parents 906880e + 9f97865 commit 867a882
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// Gigya SDK core implementation.
api 'com.github.SAP.gigya-android-sdk:gigya-android-sdk-core:core-v5.1.3'
api 'com.github.SAP.gigya-android-sdk:gigya-android-sdk-core:core-v5.1.4'
api 'com.google.code.gson:gson:2.8.6'
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class GigyaFlutterPlugin : FlutterPlugin, MethodCallHandler {
"linkToSocial" -> sdk.resolveLinkToSocial(call.arguments, result)
"resolveSetAccount" -> sdk.resolveSetAccount(call.arguments, result)
"forgotPassword" -> sdk.forgotPassword(call.arguments, result)
"initSdk" -> sdk.initSdk(call.arguments, result)
else -> result.notImplemented()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,29 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
});
}

/**
* Init SDK.
*/
fun initSdk(arguments: Any, channelResult: MethodChannel.Result) {
val apiKey: String? = (arguments as Map<*, *>)["apiKey"] as String?
if (apiKey == null) {
channelResult.success(mapOf("success" to false))

currentResult!!.error(MISSING_PARAMETER_ERROR, MISSING_PARAMETER_MESSAGE, mapOf<String, Any>())
return
}
val apiDomain: String? = (arguments as Map<*, *>)["apiDomain"] as String?
if (apiDomain == null) {
channelResult.success(mapOf("success" to false))

currentResult!!.error(MISSING_PARAMETER_ERROR, MISSING_PARAMETER_MESSAGE, mapOf<String, Any>())
return
}
sdk.init(apiKey, apiDomain);

channelResult.success(mapOf("success" to true))
}

/**
* Logout of existing session.
*/
Expand Down
13 changes: 0 additions & 13 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
PODS:
- AppAuth (1.4.0):
- AppAuth/Core (= 1.4.0)
- AppAuth/ExternalUserAgent (= 1.4.0)
- AppAuth/Core (1.4.0)
- AppAuth/ExternalUserAgent (1.4.0)
- FBSDKCoreKit (5.15.1):
- FBSDKCoreKit/Basics (= 5.15.1)
- FBSDKCoreKit/Core (= 5.15.1)
Expand Down Expand Up @@ -39,17 +34,12 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_facebook_login (from `.symlinks/plugins/flutter_facebook_login/ios`)
- gigya_flutter_plugin (from `.symlinks/plugins/gigya_flutter_plugin/ios`)
- google_sign_in (from `.symlinks/plugins/google_sign_in/ios`)

SPEC REPOS:
trunk:
- AppAuth
- FBSDKCoreKit
- FBSDKLoginKit
- Gigya
- GoogleSignIn
- GTMAppAuth
- GTMSessionFetcher

EXTERNAL SOURCES:
Flutter:
Expand All @@ -58,11 +48,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_facebook_login/ios"
gigya_flutter_plugin:
:path: ".symlinks/plugins/gigya_flutter_plugin/ios"
google_sign_in:
:path: ".symlinks/plugins/google_sign_in/ios"

SPEC CHECKSUMS:
AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
FBSDKCoreKit: 1d5acf7c9d7a2f92bb1a242dc60cae5b7adb91df
FBSDKLoginKit: f1ea8026a58b52d30c9f2e6a58ca7d813619fb83
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
Expand Down
25 changes: 22 additions & 3 deletions ios/Classes/GigyaSdkWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {

init(accountSchema: T.Type) {
// Initializing the Gigya SDK instance.
GigyaDefinitions.versionPrefix = "flutter_0.0.2_"
GigyaDefinitions.versionPrefix = "flutter_0.1.2_"
sdk = Gigya.sharedInstance(accountSchema)
}

Expand Down Expand Up @@ -212,6 +212,23 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
}
})
}

/**
Init SDK
*/
func initSdk(arguments: [String: Any], result: @escaping FlutterResult) {
guard let apiKey = arguments["apiKey"] as? String else {
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}
guard let apiDomain = arguments["apiDomain"] as? String else {
result(FlutterError(code: PluginErrors.missingParameterError, message: PluginErrors.missingParameterMessage, details: nil))
return
}
sdk?.initFor(apiKey: apiKey, apiDomain: apiDomain)

result(["success": true])
}

/**
Social login with given provider & provider sessions.
Expand Down Expand Up @@ -322,7 +339,9 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
let screenSet = arguments["screenSet"] as? String else {
return
}


let parameters = arguments["parameters"] as? [String: Any] ?? [:]

// Create streamer
var screenSetsEventHandler: ScreenSetsStreamHandler? = ScreenSetsStreamHandler()
let eventChannel = FlutterEventChannel(name: "screensetEvents", binaryMessenger: SwiftGigyaFlutterPlugin.registrar!.messenger())
Expand All @@ -336,7 +355,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
sdk?.showScreenSet(
with: screenSet,
viewController: viewController,
params: arguments) { [weak self] event in
params: parameters) { [weak self] event in
switch event {
case .error(let event):
screenSetsEventHandler?.sink?(["event":"onError", "data" : event])
Expand Down
3 changes: 3 additions & 0 deletions ios/Classes/SwiftGigyaFlutterPluginTyped.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class SwiftGigyaFlutterPluginTyped<T: GigyaAccountProtocol> : NSObject, F

enum GigyaMethods: String {
case getPlatformVersion
case initSdk
case sendRequest
case loginWithCredentials
case registerWithCredentials
Expand Down Expand Up @@ -94,6 +95,8 @@ public class SwiftGigyaFlutterPluginTyped<T: GigyaAccountProtocol> : NSObject, F
sdk?.resolveSetAccount(arguments: args, result: result)
case .forgotPassword:
sdk?.forgotPassword(arguments: args, result: result)
case .initSdk:
sdk?.initSdk(arguments: args, result: result)
default:
result(nil)
}
Expand Down
22 changes: 21 additions & 1 deletion lib/gigya_flutter_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum Methods {
removeConnection,
showScreenSet,
forgotPassword,
initSdk,
}

extension MethodsExt on Methods {
Expand Down Expand Up @@ -195,9 +196,28 @@ class GigyaSdk with DataMixin {
return result;
}

/// Init SDK using apiKey and apiDomain
Future<Map<String, dynamic>?> initSdk(String apiKey, String apiDomain, [bool forceLogout = true]) async {
if (forceLogout) {
await logout();
}

final result = await _channel.invokeMapMethod<String, dynamic>(
Methods.initSdk.name,
{
'apiKey': apiKey,
'apiDomain': apiDomain,
},
).timeout(_getTimeout(Methods.initSdk), onTimeout: () {
debugPrint('A timeout that was defined in the request is reached');
return _timeoutError();
});
return result;
}

/// Perform a social login given the [provider] identity.
/// This call will specifically call the "notifySocialLogin" endpoint.
/// All social provider integration is the host's responsibility.
/// All social provider integration is the host's responsibiliy.
///
/// Long timeout is set (5 minutes) in order to make sure that long sign in processes will not break.
Future<Map<String, dynamic>?> socialLogin(SocialProvider provider,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: gigya_flutter_plugin
description: SAP Gigya Flutter plugin
version: 0.1.1
version: 0.1.2
homepage: https://github.com/SAP/gigya-flutter-plugin

environment:
Expand Down

0 comments on commit 867a882

Please sign in to comment.