-
Notifications
You must be signed in to change notification settings - Fork 6
MOBILE-53: Add settings.open action for js bridge #696
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,9 @@ public enum class WebViewAction { | |
|
|
||
| @SerializedName(value = "permission.request") | ||
| PERMISSION_REQUEST, | ||
|
|
||
| @SerializedName(value = "settings.open") | ||
| SETTINGS_OPEN, | ||
|
Comment on lines
60
to
+65
|
||
| } | ||
|
|
||
| @InternalMindboxApi | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,7 @@ import cloud.mindbox.mobile_sdk.inapp.domain.models.InAppType | |||||||||||||||||||
| import cloud.mindbox.mobile_sdk.inapp.domain.models.InAppTypeWrapper | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.inapp.domain.models.Layer | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.inapp.presentation.InAppCallback | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.inapp.presentation.MindboxNotificationManager | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.inapp.presentation.MindboxView | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.inapp.webview.* | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.logger.mindboxLogD | ||||||||||||||||||||
|
|
@@ -36,6 +37,7 @@ import cloud.mindbox.mobile_sdk.models.getShortUserAgent | |||||||||||||||||||
| import cloud.mindbox.mobile_sdk.models.operation.request.FailureReason | ||||||||||||||||||||
| import cloud.mindbox.mobile_sdk.utils.MindboxUtils.Stopwatch | ||||||||||||||||||||
| import com.google.gson.Gson | ||||||||||||||||||||
| import com.google.gson.annotations.SerializedName | ||||||||||||||||||||
| import kotlinx.coroutines.CancellationException | ||||||||||||||||||||
| import kotlinx.coroutines.CompletableDeferred | ||||||||||||||||||||
| import kotlinx.coroutines.cancel | ||||||||||||||||||||
|
|
@@ -77,6 +79,7 @@ internal class WebViewInAppViewHolder( | |||||||||||||||||||
| private val gatewayManager: GatewayManager by mindboxInject { gatewayManager } | ||||||||||||||||||||
| private val sessionStorageManager: SessionStorageManager by mindboxInject { sessionStorageManager } | ||||||||||||||||||||
| private val permissionManager: PermissionManager by mindboxInject { permissionManager } | ||||||||||||||||||||
| private val mindboxNotificationManager: MindboxNotificationManager by mindboxInject { mindboxNotificationManager } | ||||||||||||||||||||
| private val appContext: Application by mindboxInject { appContext } | ||||||||||||||||||||
| private val operationExecutor: WebViewOperationExecutor by lazy { | ||||||||||||||||||||
| MindboxWebViewOperationExecutor() | ||||||||||||||||||||
|
|
@@ -149,6 +152,7 @@ internal class WebViewInAppViewHolder( | |||||||||||||||||||
| registerSuspend(WebViewAction.LOCAL_STATE_SET, ::handleLocalStateSetAction) | ||||||||||||||||||||
| registerSuspend(WebViewAction.LOCAL_STATE_INIT, ::handleLocalStateInitAction) | ||||||||||||||||||||
| registerSuspend(WebViewAction.PERMISSION_REQUEST, ::handlePermissionAction) | ||||||||||||||||||||
| register(WebViewAction.SETTINGS_OPEN, ::handleSettingsOpenAction) | ||||||||||||||||||||
| register(WebViewAction.READY) { | ||||||||||||||||||||
| handleReadyAction( | ||||||||||||||||||||
| configuration = configuration, | ||||||||||||||||||||
|
|
@@ -305,6 +309,22 @@ internal class WebViewInAppViewHolder( | |||||||||||||||||||
| return gson.toJson(permissionRequestResult) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private fun handleSettingsOpenAction(message: BridgeMessage.Request): String { | ||||||||||||||||||||
| val payload: String = message.payload ?: BridgeMessage.EMPTY_PAYLOAD | ||||||||||||||||||||
| val settingsOpenRequest: SettingsOpenRequest? = gson.fromJson<SettingsOpenRequest>(payload).getOrNull() | ||||||||||||||||||||
| requireNotNull(settingsOpenRequest) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| val targetType = settingsOpenRequest.target.enumValue<SettingsOpenTargetType>() | ||||||||||||||||||||
|
Comment on lines
+315
to
+317
|
||||||||||||||||||||
| requireNotNull(settingsOpenRequest) | |
| val targetType = settingsOpenRequest.target.enumValue<SettingsOpenTargetType>() | |
| requireNotNull(settingsOpenRequest) { "Invalid or missing settings open request payload" } | |
| val targetString: String? = settingsOpenRequest.target | |
| val targetType: SettingsOpenTargetType? = | |
| runCatching { targetString?.enumValue<SettingsOpenTargetType>() }.getOrNull() | |
| requireNotNull(targetType) { "Unknown settings target: $targetString" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
requestPermission(), theelsebranch later in this method callsopenNotificationSettings(activity)without the newchannelIdargument. Since the overrideopenNotificationSettings(activity: Activity, channelId: String?)doesn’t declare a default value, this will not compile; passnullexplicitly (or add a 1-arg overload / default on the override).