mirror of
https://github.com/readest/readest.git
synced 2026-04-29 12:00:49 +00:00
fix(iap): open external app for payment (#2465)
This commit is contained in:
parent
bfac67d3f0
commit
6d5b16ea8b
14 changed files with 179 additions and 4 deletions
|
|
@ -75,6 +75,11 @@ class SetScreenBrightnessRequestArgs {
|
|||
var brightness: Double? = null // 0.0 to 1.0
|
||||
}
|
||||
|
||||
@InvokeArg
|
||||
class OpenExternalUrlArgs {
|
||||
var url: String? = null
|
||||
}
|
||||
|
||||
@InvokeArg
|
||||
class FetchProductsRequestArgs {
|
||||
val productIds: List<String>? = null
|
||||
|
|
@ -660,4 +665,21 @@ class NativeBridgePlugin(private val activity: Activity): Plugin(activity) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command
|
||||
fun open_external_url(invoke: Invoke) {
|
||||
val args = invoke.parseArgs(OpenExternalUrlArgs::class.java)
|
||||
val url = args.url ?: ""
|
||||
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
activity.startActivity(intent)
|
||||
val ret = JSObject()
|
||||
ret.put("success", true)
|
||||
invoke.resolve(ret)
|
||||
} catch (e: Exception) {
|
||||
invoke.reject("Failed to open URL: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue