Mobile Integration Guide
The Accrue wallet can be seamlessly integrated into your mobile applications using our native SDKs. These SDKs provide a streamlined integration experience, combining wallet lifecycle management and deep linking capabilities in a single package.
Platform SDKs
Accrue provides native SDKs for all major mobile platforms. Choose the SDK that matches your development environment:
Key Features
All Accrue mobile SDKs provide:
- Native Integration - Embed the wallet directly within your app for a seamless user experience
- Deep Linking - Navigate users to specific screens within the wallet
- User Data Passing - Associate your app's user data with Accrue profiles
- Authentication Inheritance - Optional feature to use your app's authentication state
- Event Handling - Receive and respond to user actions in the wallet
React Native SDK
The Accrue React Native SDK is available in two flavors:
Installation
Bare SDK
npm install --save @accrue-savings/react-native-sdk
Expo SDK
npm install --save @accrue-savings/expo-sdk
After installation, link the dependencies:
# For npm
npx accrue-sdk link
# For yarn
yarn accrue-sdk link
# For pnpm
pnpm exec accrue-sdk link
Usage Example
import React, { useState } from "react";
import { SafeAreaView } from "react-native";
import {
AccrueWalletWidget,
UserSignInPayload,
} from "@accrue-savings/<expo-sdk|react-native-sdk>";
export default function AccrueWalletView({ route }) {
const params = route.getParams();
const [signedInUserPayload, setSignedInUserPayload] = useState<UserSignInPayload>();
return (
<SafeAreaView style={{ flex: 1, backgroundColor: "white" }}>
<AccrueWalletWidget
// For production releases set sandbox to `false` or remove the prop
sandbox={true}
// Merchant ID from Accrue (different values for production and sandbox)
merchantId={params.merchantId}
// User data to associate with Accrue profile
userData={{
referenceId: "123e4567-e89b-12d3-a456-426614174000",
email: "user@email.com",
phoneNumber: "+12125559999",
}}
// Handle user sign-in events
onSignIn={(user) => {
setSignedInUserPayload(user);
}}
// Deep linking token (optional)
redirectionToken={params.to}
// Optional container styling
style={{ flex: 1 }}
/>
</SafeAreaView>
);
}
Props
Prop | Type | Required | Description |
---|---|---|---|
merchantId | string | Yes | Your unique merchant ID from Accrue |
sandbox | boolean | No | Set to true for testing, false for production |
userData | Object | No | User data to associate with Accrue profile |
onSignIn | Function | No | Callback for user sign-in events |
redirectionToken | string | No | Token for deep linking to specific screens |
style | ViewStyle | No | Container styling for the WebView |
iOS SDK
The Accrue iOS SDK is available as a Swift Package Manager package.
Installation
- In Xcode, select
File
>Swift Packages
>Add Package Dependency
- Enter the repository URL:
https://github.com/accrue-savings/ios-sdk
- Follow the prompts to complete the installation
Usage Example
import SwiftUI
import AccrueIosSDK
import WebKit
struct ContentView: View {
@StateObject private var contextData = AccrueContextData(
userData: AccrueUserData(
// A unique reference id for the user
referenceId: "yourReferenceId",
// User email
email: "email@example.com",
// User US phone number
phoneNumber: "+12125559999",
// Additional user data
additionalData: ["firstName": "John", "lastName": "Doe"]
),
// Settings data
settingsData: AccrueSettingsData(
// Whether to inherit authentication from parent app
shouldInheritAuthentication: true
)
)
private var AccrueWalletView: AccrueWallet {
AccrueWallet(
// Merchant ID from Accrue
merchantId: "yourMerchantId",
// Deep linking token (optional)
redirectionToken: "yourRedirectionToken",
// Sandbox mode for testing
isSandbox: true,
// Context data with user and settings info
contextData: contextData,
// Action handler callback
onAction: handleOnAction
)
}
var body: some View {
AccrueWalletView
Button("Go to home screen") {
// Send event to the wallet
AccrueWalletView.handleEvent(event: "AccrueTabPressed")
}
}
// Handle actions from the wallet
func handleOnAction(action: String) {
print("action with data: \(action)")
}
}
Props
Accure Wallet View is the primary UI for the wallet. It is instantiated with the following propertues
Prop | Type | Required | Description |
---|---|---|---|
merchantId | String | Yes | Your unique merchant ID |
redirectionToken | String | No | Token for deep linking |
isSandbox | Bool | No | Development mode flag |
contextData | AccrueContextData | Yes | User and settings data |
onAction | (String) -> Void | No | Action handler callback |
The contextData: AccrueContextData
properties is composed of two types.
The userData: AccrueUserData
struct is used to link identities between the application and the wallet.
Property | Type | Required | Description |
---|---|---|---|
referenceId | string | Yes | A unique reference ID for the user |
email | string | No | User's email address |
phoneNumber | string | Yes | User's US phone number |
additionalData | object | No | Extra user information including firstName and lastName |
The settingsData: AccrueSettingsData
struct has a single property which determines if Accure perform additional authentication of the user.
Property | Type | Required | Description |
---|---|---|---|
shouldInheritAuthentication | boolean | No | Whether to use your app's authentication state |
Android SDK
The Accrue Android SDK is available as a package on GitHub.
Installation
Add the GitHub package repository to your build.gradle.kts
file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/accrue-savings/android-sdk")
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
Set up GitHub credentials (you can use the provided token):
export GITHUB_USERNAME="accruesavings"
export GITHUB_TOKEN="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"
Add the dependency:
dependencies {
implementation("com.accruesavings:androidsdk:v1.0.0")
}
Usage Example
// Create user data object
val userData = AccrueUserData(
referenceId = "<your_unique_user_id>",
phoneNumber = "<users_phone_number>",
email = "<users_email>",
additionalData = mapOf(
"firstName" to "John",
"lastName" to "Doe"
)
)
// Create settings data object
val settingsData = AccrueSettingsData(
shouldInheritAuthentication = true
)
// Combine into context data
val contextData = AccrueContextData(userData, settingsData)
// Create wallet fragment
val fragment = AccrueWallet.newInstance(
contextData = contextData,
redirectionToken = redirectionToken,
isSandbox = true,
merchantId = merchantId,
onAction = mapOf(
AccrueAction.SignInButtonClicked to {
// Handle sign in button click
},
AccrueAction.RegisterButtonClicked to {
// Handle register button click
}
)
)
// Add fragment to layout
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment)
.commit()
Props
Accure Wallet View is the primary UI for the wallet. It is instantiated with the following propertues
Prop | Type | Required | Description |
---|---|---|---|
merchantId | String | Yes | Your unique merchant ID |
redirectionToken | String | No | Token for deep linking |
isSandbox | Boolean | No | Development mode flag |
contextData | AccrueContextData | Yes | User and settings data |
onAction | Map<AccrueAction, () -> Unit> | No | Action handlers |
The contextData: AccrueContextData
properties is composed of two types.
The userData: AccrueUserData
struct is used to link identities between the application and the wallet.
Property | Type | Required | Description |
---|---|---|---|
referenceId | string | Yes | A unique reference ID for the user |
email | string | No | User's email address |
phoneNumber | string | Yes | User's US phone number |
additionalData | object | No | Extra user information including firstName and lastName |
The settingsData: AccrueSettingsData
struct has a single property which determines if Accure perform additional authentication of the user.
Property | Type | Required | Description |
---|---|---|---|
shouldInheritAuthentication | boolean | No | Whether to use your app's authentication state |
Authentication
All SDKs support authentication delegation, which allows the wallet to use your app's for authentication. When enabled (shouldInheritAuthentication = true
):
- All identity must be handled in your app
- A
referenceId
must be provided. - The wallet will use the provided phone number and email for user notifications
- Phone number and email cannot be changed on the Accrue platform
Call backs for events in the Wallet
The SDKs provide callbacks for events in the SDK:
- React Native:
onSignIn
callback with user data - iOS/Android: Action callbacks for sign-in and registration events
Sending Events to the Wallet from the application
For iOS and Android, you can send events to the wallet:
// iOS
AccrueWalletView.handleEvent(event: "AccrueTabPressed")
// Android
accrueWallet.handleEvent("AccrueTabPressed")
Currently supported events:
AccrueTabPressed
: Notifies the wallet when the user navigates to the tab containing the wallet