$ npm install @argyleio/argyle-plugin-react-native --save
or $ yarn add @argyleio/argyle-plugin-react-native
$ react-native link @argyleio/argyle-plugin-react-native
(if react-native > 0.60.x, this step is not needed)
minimum deployment target needs to be at least 11.0
$ yarn add react-native-swift
(so that project can run swift code, mostly configuration thing)
$ react-native link react-native-swift
(even for react-native version > 0.60.x projects, it's mostly configuration, not adding any actual projects)
$ cd ios
$ pod install
$ cd ios
$ pod install
while installing pods, if getting error about React dependency, need to add :modular_headers => true
for the React
pod. i.e.:
pod 'React', path: rn_path, subspecs: [
'Core',
'RCTActionSheet',
'DevSupport',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
'CxxBridge'
], :modular_headers => true
- download native Argyle.framework (from https://github.com/argyle-systems/Argyle_iOS)
- Add Argyle.framework to root ios/Frameworks folder (add Frameworks folder not present yet)
- Build Settings > Always Embed Swift Standard Libraries > YES
- Select root project -> main target -> build phases 1. if there's no "Embedded frameworks" phase 1. click + -> "new copy files phase" 2. click "Destination" and select "Frameworks" 3. click + below and add Argyle.framework 4. You can rename this phase to "Embedded frameworks" (optional) 2. if "Embedded frameworks" phase exists, just click + below and add Argyle.framework
- (should be there) make sure
ARArgyleSdk.xcodeproj
has$(PROJECT_DIR)/../../../ios/Frameworks
steps from without pods
part, plus
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜@argyleio/argyle-plugin-react-native
and addARArgyleSdk.xcodeproj
- In XCode, in the project navigator, select your project. Add
libARArgyleSdk.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.ARArgyleSdkPackage;
to the imports at the top of the file - Add
new ARArgyleSdkPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':@argyleio/argyle-plugin-react-native' project(':@argyleio/argyle-plugin-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/@argyleio/argyle-plugin-react-native/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':@argyleio/argyle-plugin-react-native')
import ArgyleSdk from '@argyleio/argyle-plugin-react-native'
// Configure the SDK before hand, once. only call ArgyleSdk.start() when the UI is needed
// ArgyleSdk.loginWith("your_plugin_key", "server_url", "existing_user_token")
ArgyleSdk.loginWith("your_plugin_key", "https://api-sandbox.develop.argyle.io", "")
ArgyleSdk.onUserCreated(res => console.log("onUserCreated", res))
ArgyleSdk.onAccountConnected(res => console.log("onAccountConnected", res))
ArgyleSdk.onAccountRemoved(res => console.log("onAccountRemoved", res))
ArgyleSdk.onError(error => {
console.log("onError", error)
if (error === ArgyleSdk.errorCodes.EXPIRED_TOKEN) {
setTimeout(() => {
// Simulated timeout before updating the token
ArgyleSdk.updateToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTk4MTA5OTE2LCJqdGkiOiJkZDI5ZDJjYWUxMjQ0OTlhYjY1NzlhOWEwMmQzZTMzNSIsInVzZXJfaWQiOiJlNjQwMzE5Zi1mYWJjLTRjMWYtYjIyMS0yZGFmNWFkMWY0NjEiLCJjbGllbnRfaWQiOiI0ODA3MTZkYy05ZDc3LTQ0OTEtYjVhNC0xODc5MzkxYjhmNjUiLCJpc19kZXZfb25seSI6dHJ1ZX0.BxE92-Iu67KM0CF9OihsCJjnxdagzCixZVvMmy8KWvQ")
}, 300)
}
})
ArgyleSdk.onTokenExpired(res => console.log("onTokenExpired", res))
// ArgyleSdk.dataPartners(["uber", "postmates"])
// ArgyleSdk.dataPartners(null)
// Launches the SDK UI. Use on-click some button
ArgyleSdk.start()