|
| 1 | +# 📱 Mobile App Integration |
| 2 | + |
| 3 | +## **Sign-In With Frequency (SIWF) SDK Integration Guide** |
| 4 | + |
| 5 | +🚀 **The SIWF SDK provides a seamless authentication experience for mobile apps. This guide walks you through integrating the SIWF SDK into your **iOS** or **Android** app.** |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## 📌 **Index** |
| 10 | +1. 📱 [iOS](#iOS) |
| 11 | +2. 🤖 [Android](#Android) |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## 📱 **iOS** |
| 16 | + |
| 17 | + |
| 18 | +<details> |
| 19 | +<summary>📥 Installation</summary> |
| 20 | + |
| 21 | +### ⚙️ Requirements |
| 22 | +- iOS 15.0 or later |
| 23 | +- macOS 11.0 or later |
| 24 | +- Swift |
| 25 | + |
| 26 | +### 📦 Installing the SIWF SDK |
| 27 | +You can install the SIWF SDK via **Swift Package Manager (SPM)**: |
| 28 | + |
| 29 | +1. Open Xcode and navigate to **File → Add Packages**. |
| 30 | +2. Enter the repository URL: |
| 31 | + ``` |
| 32 | + https://github.com/ProjectLibertyLabs/siwf-sdk-ios |
| 33 | + ``` |
| 34 | +3. Select the latest stable version and add it to your project. |
| 35 | + |
| 36 | +</details> |
| 37 | + |
| 38 | +<details> |
| 39 | + <summary>🛠 Usage</summary> |
| 40 | + |
| 41 | +### **Displaying the SIWF Sign-In Button** |
| 42 | +To create a SIWF sign-in button, use the `Siwf.createSignInButton` method: |
| 43 | + |
| 44 | +```swift |
| 45 | +import Siwf |
| 46 | + |
| 47 | +Siwf.createSignInButton(mode: .primary, authRequest: authRequest) |
| 48 | +``` |
| 49 | + |
| 50 | +</details> |
| 51 | + |
| 52 | +<details> |
| 53 | + <summary>🔄 Handling Authorization Callbacks</summary> |
| 54 | + |
| 55 | +### **Handling Authorization Redirects** |
| 56 | +Use `onOpenURL` and `Siwf.handleRedirectUrl` to handle deep links and retreive the authentication code. |
| 57 | + |
| 58 | +</details> |
| 59 | + |
| 60 | +<details> |
| 61 | +<summary>🔑 Process Authorization Code</summary><br /> |
| 62 | + |
| 63 | +On your backend services process the authorization code and start your session. |
| 64 | + |
| 65 | +Resources: |
| 66 | +- [SIWF Documentation on Processing a Result](https://projectlibertylabs.github.io/siwf/v2/docs/Actions/Response.html) |
| 67 | +- [Frequency Gateway SSO Tutorial](https://projectlibertylabs.github.io/gateway/GettingStarted/SSO.html) |
| 68 | +</details> |
| 69 | + |
| 70 | +**For more info see: [SIWF iOS SDK Source Code + Demo App](https://github.com/ProjectLibertyLabs/siwf-sdk-ios)** |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 🤖 **Android** |
| 75 | + |
| 76 | +<details> |
| 77 | +<summary>📥 Installation</summary> |
| 78 | + |
| 79 | +### ⚙️ Requirements |
| 80 | +- Android API level **24** or later |
| 81 | +- Java **11+** |
| 82 | + |
| 83 | +### 📦 Installing the SIWF SDK |
| 84 | +To install the SIWF SDK via **Gradle**, add the following to your `build.gradle` file: |
| 85 | + |
| 86 | +```gradle |
| 87 | +dependencies { |
| 88 | + implementation 'io.projectliberty:siwf:1.0.0' |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +</details> |
| 93 | + |
| 94 | +<details> |
| 95 | + <summary>🛠 Usage</summary> |
| 96 | + |
| 97 | +### **Displaying the SIWF Sign-In Button** |
| 98 | +To create a SIWF sign-in button in your Android app, use: |
| 99 | + |
| 100 | +```kotlin |
| 101 | +import io.projectliberty.siwf.Siwf |
| 102 | +import io.projectliberty.models.SiwfButtonMode |
| 103 | + |
| 104 | +Siwf.CreateSignInButton( |
| 105 | + mode = SiwfButtonMode.PRIMARY, |
| 106 | + authRequest = authRequest |
| 107 | +) |
| 108 | +``` |
| 109 | + |
| 110 | +</details> |
| 111 | + |
| 112 | +<details> |
| 113 | + <summary>🔄 Handling Authorization Callbacks</summary> |
| 114 | + |
| 115 | +### **Handling Authorization Redirects** |
| 116 | +Update your `AndroidManifest.xml` with intent filters for authentication callbacks: |
| 117 | + |
| 118 | +```xml |
| 119 | +<activity |
| 120 | + android:name="io.projectliberty.helpers.AuthCallbackActivity" |
| 121 | + ... |
| 122 | + <intent-filter android:autoVerify="true"> |
| 123 | + ... |
| 124 | + <data |
| 125 | + android:scheme="http" |
| 126 | + android:host="localhost" |
| 127 | + android:port="3000" |
| 128 | + android:path="/login/callback" /> |
| 129 | + </intent-filter> |
| 130 | + <intent-filter android:autoVerify="true"> |
| 131 | + ... or ... |
| 132 | + <data |
| 133 | + android:scheme="siwfdemoapp" |
| 134 | + android:host="login" /> |
| 135 | + </intent-filter> |
| 136 | +</activity> |
| 137 | +``` |
| 138 | + |
| 139 | +Then, use a `BroadcastReceiver()` to receive the authorization code. |
| 140 | + |
| 141 | +</details> |
| 142 | + |
| 143 | +<details> |
| 144 | +<summary>🔑 Process Authorization Code</summary><br /> |
| 145 | + |
| 146 | +On your backend services process the authorization code and start your session. |
| 147 | + |
| 148 | +Resources: |
| 149 | +- [SIWF Documentation on Processing a Result](https://projectlibertylabs.github.io/siwf/v2/docs/Actions/Response.html) |
| 150 | +- [Frequency Gateway SSO Tutorial](https://projectlibertylabs.github.io/gateway/GettingStarted/SSO.html) |
| 151 | +</details> |
| 152 | + |
| 153 | +**For more info see: [SIWF Android SDK Source Code + Demo App](https://github.com/ProjectLibertyLabs/siwf-sdk-android)** |
0 commit comments