Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc optional #1

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions android/src/main/java/com/expofp/ExpofpViewManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,35 @@ class ExpofpViewManager : SimpleViewManager<View>() {

@ReactProp(name = "settings")
fun setSettings(view: FplanView, settingsMap: ReadableMap?) {
val context = reactContext?.applicationContext ?: return
val application = context as? Application ?: return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val activity = reactContext?.currentActivity
if (activity != null) {
ActivityCompat.requestPermissions(
activity,
arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT),
2
settingsMap?.let {
var appKey = settingsMap.getString("appKey")
val token = settingsMap.getString("token")
val secret = settingsMap.getString("secret")
if (appKey != null && token != null && secret != null) {
val context = reactContext?.applicationContext ?: return
val application = context as? Application ?: return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val activity = reactContext?.currentActivity
if (activity != null) {
ActivityCompat.requestPermissions(
activity,
arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT),
2
)
}
}
val lpSettings = com.expofp.crowdconnected.Settings(
settingsMap.getString("appKey") ?: "",
settingsMap.getString("token") ?: "",
settingsMap.getString("secret") ?: "",
Mode.IPS_AND_GPS
)
lpSettings.setServiceNotificationInfo("Knowledge - ServiceNow is running", R.drawable.common_google_signin_btn_icon_dark);
lpSettings.setAlias("onesignal_user_id", it.getString("oneSignalUserId") ?: "");
val locationProvider = CrowdConnectedProvider(application, lpSettings)
GlobalLocationProvider.init(locationProvider)
GlobalLocationProvider.start()
}
}
settingsMap?.let {
val lpSettings = com.expofp.crowdconnected.Settings(
settingsMap.getString("appKey") ?: "",
settingsMap.getString("token") ?: "",
settingsMap.getString("secret") ?: "",
Mode.IPS_AND_GPS
)
lpSettings.setServiceNotificationInfo("Knowledge - ServiceNow is running", R.drawable.common_google_signin_btn_icon_dark);
lpSettings.setAlias("onesignal_user_id", it.getString("oneSignalUserId") ?: "");
val locationProvider = CrowdConnectedProvider(application, lpSettings)
GlobalLocationProvider.init(locationProvider)
GlobalLocationProvider.start()
view.init(it.getString("url") ?: "", com.expofp.fplan.models.Settings().withGlobalLocationProvider());
}
}
Expand Down
35 changes: 19 additions & 16 deletions ios/ExpofpViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ class ExpoFPViewProxy: UIView {

@objc var settings: NSDictionary = [:] {
didSet {
if let url = settings["url"] as? NSString,
let appKey = settings["appKey"] as? String,
let token = settings["token"] as? String,
let secret = settings["secret"] as? String {
let ccSettings = Settings(
appKey,
token,
secret,
Mode.IPS_AND_GPS
);
if let onesignalUserId = settings["oneSignalUserId"] as? String {
ccSettings.addAlias("onesignal_user_id", onesignalUserId)
if let url = settings["url"] as? NSString {
if let appKey = settings["appKey"] as? String,
let token = settings["token"] as? String,
let secret = settings["secret"] as? String {
let ccSettings = Settings(
appKey,
token,
secret,
Mode.IPS_AND_GPS
);
if let onesignalUserId = settings["oneSignalUserId"] as? String {
ccSettings.addAlias("onesignal_user_id", onesignalUserId)
}
let locationProvider: LocationProvider = CrowdConnectedProvider(ccSettings);
GlobalLocationProvider.initialize(locationProvider)
GlobalLocationProvider.start()
dataStore.url = url
} else {
dataStore.url = url
}
let locationProvider: LocationProvider = CrowdConnectedProvider(ccSettings);
GlobalLocationProvider.initialize(locationProvider)
GlobalLocationProvider.start()
dataStore.url = url
}
}
}
Expand Down