forked from react-native-webview/react-native-webview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from derniercri/feat/gigya
Add gigya implementation
- Loading branch information
Showing
30 changed files
with
262 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
56 changes: 56 additions & 0 deletions
56
android/src/main/java/com/reactnativecommunity/webview/RNCGigya.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.reactnativecommunity.webview | ||
|
||
import android.app.Application | ||
import android.webkit.WebResourceRequest | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import com.gigya.android.sdk.Gigya | ||
import com.gigya.android.sdk.GigyaPluginCallback | ||
import com.gigya.android.sdk.account.models.GigyaAccount | ||
import com.gigya.android.sdk.session.SessionInfo | ||
import com.gigya.android.sdk.ui.plugin.IGigyaWebBridge | ||
|
||
class RNCGigya(context: Application, apiKey: String, apiDomain: String) { | ||
private var gigya: Gigya<GigyaAccount> | ||
|
||
init { | ||
Gigya.setApplication(context) | ||
gigya = Gigya.getInstance(GigyaAccount::class.java) | ||
gigya.init(apiKey, apiDomain) | ||
} | ||
|
||
fun initialize(sessionToken: String, sessionSecret: String, webview: WebView) { | ||
attachBridge(webview) | ||
logUser(sessionToken = sessionToken, sessionSecret = sessionSecret) | ||
} | ||
|
||
private fun logUser(sessionToken: String, sessionSecret: String) { | ||
val session = SessionInfo(sessionSecret, sessionToken) | ||
gigya.setSession(session) | ||
} | ||
|
||
|
||
private fun attachBridge(webview: WebView) { | ||
var webBridge: IGigyaWebBridge<GigyaAccount>? = null | ||
|
||
/* | ||
Make sure you enable javascript for your WebView instance. | ||
*/ | ||
val webSettings = webview.settings | ||
webSettings.javaScriptEnabled = true | ||
|
||
webBridge = gigya.createWebBridge() | ||
webBridge?.attachTo(webview, object: GigyaPluginCallback<GigyaAccount>() {}, null) | ||
|
||
/* | ||
Make sure to attach the GigyaWebBridge to your WebViewClient instance. | ||
*/ | ||
webview.webViewClient = (object: WebViewClient() { | ||
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean { | ||
val uri = request?.url | ||
val uriString = uri.toString() | ||
return webBridge?.invoke(uriString) ?: false | ||
} | ||
}) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
android/src/main/java/com/reactnativecommunity/webview/RNCGigyaCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.reactnativecommunity.webview; | ||
|
||
class RNCGigyaCredentials { | ||
String sessionToken; | ||
String sessionSecret; | ||
String apiKey; | ||
String apiDomain; | ||
|
||
RNCGigyaCredentials(String sessionToken, String sessionSecret, String apiKey, String apiDomain) { | ||
this.sessionToken = sessionToken; | ||
this.sessionSecret = sessionSecret; | ||
this.apiKey = apiKey; | ||
this.apiDomain = apiDomain; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import WebView from './lib/WebView'; | ||
import WebView from './src/WebView'; | ||
|
||
export { WebView }; | ||
export default WebView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// RNCGigya.swift | ||
// RNCWebView | ||
// | ||
// Created by Martin Frouin on 19/10/2023. | ||
// Copyright © 2023 Facebook. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import WebKit | ||
import Gigya | ||
|
||
@objc public class RNCGigya: NSObject { | ||
let gigya = Gigya.sharedInstance() | ||
|
||
@objc public func initialize(controller: UIViewController, webview: WKWebView, sessionToken: String, sessionSecret: String, apiKey: String, apiDomain: String) { | ||
gigya.initFor(apiKey: apiKey, apiDomain: apiDomain) | ||
|
||
self.attachBridge(controller: controller, webview: webview) | ||
self.logUser(sessionToken: sessionToken, sessionSecret: sessionSecret) | ||
} | ||
|
||
func attachBridge(controller: UIViewController, webview: WKWebView) { | ||
let webBridge = gigya.createWebBridge() | ||
|
||
webBridge.attachTo(webView: webview, viewController: controller) { _ in } | ||
|
||
} | ||
|
||
func logUser(sessionToken: String, sessionSecret: String) { | ||
let session = GigyaSession(sessionToken: sessionToken, secret: sessionSecret) | ||
|
||
if (session != nil) { | ||
gigya.setSession(session!) | ||
} | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// | ||
// Use this file to import your target's public headers that you would like to expose to Swift. | ||
// | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.