Skip to content

Commit

Permalink
Merge pull request #362 from blackcandy-org/android-bridge
Browse files Browse the repository at this point in the history
Add android native bridge to update theme on android app
  • Loading branch information
aidewoode committed Mar 20, 2024
2 parents e294447 + ac91df0 commit 27de0b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/javascript/helper.js
Expand Up @@ -37,8 +37,12 @@ function isiOSApp () {
return !!(window.webkit && window.webkit.messageHandlers)
}

function isAndroidApp () {
return !!(window.NativeBridge)
}

function isNativeApp () {
return isiOSApp()
return isiOSApp() || isAndroidApp()
}

export {
Expand All @@ -47,5 +51,6 @@ export {
fetchRequest,
dispatchEvent,
isiOSApp,
isAndroidApp,
isNativeApp
}
6 changes: 5 additions & 1 deletion app/javascript/native_bridge.js
@@ -1,4 +1,4 @@
import { isiOSApp } from './helper'
import { isAndroidApp, isiOSApp } from './helper'

class NativeBridge {
playAll (resourceType, resourceId) {
Expand Down Expand Up @@ -49,6 +49,10 @@ class NativeBridge {
theme
})
}

if (isAndroidApp()) {
window.NativeBridge.updateTheme(theme)
}
}

showFlashMessage (message) {
Expand Down

0 comments on commit 27de0b5

Please sign in to comment.