Testing Android intents as a receiver.

This commit is contained in:
Eric van der Vlist 2022-12-14 21:50:09 +01:00
parent b797015c57
commit e90e71d151
4 changed files with 51 additions and 0 deletions

View File

@ -26,6 +26,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="geo" />
</intent-filter>
</activity>
<provider

19
package-lock.json generated
View File

@ -12,6 +12,7 @@
"dependencies": {
"@awesome-cordova-plugins/android-full-screen": "^6.2.0",
"@awesome-cordova-plugins/geolocation": "^6.2.0",
"@awesome-cordova-plugins/web-intent": "^6.2.0",
"@capacitor-community/background-geolocation": "^1.2.6",
"@capacitor/android": "^3.4.3",
"@capacitor/core": "^3.4.3",
@ -23,6 +24,7 @@
"@suid/icons-material": "^0.5.1",
"@suid/material": "^0.8.1",
"@suid/vite-plugin": "^0.1.0",
"com-darryncampbell-cordova-plugin-intent": "^2.2.0",
"cordova-plugin-fullscreen": "^1.3.0",
"isomorphic-xml2js": "^0.1.3",
"lodash": "^4.17.21",
@ -114,6 +116,18 @@
"rxjs": "^5.5.0 || ^6.5.0 || ^7.3.0"
}
},
"node_modules/@awesome-cordova-plugins/web-intent": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/web-intent/-/web-intent-6.2.0.tgz",
"integrity": "sha512-tlbhAMAjs4i4r+TTIr5dn4sCND89gHV8i3mUh6ftY0Pedaxj1Sf0TklQZE9w3nC/OUQeX/SctmNbeN3tTYQxTw==",
"dependencies": {
"@types/cordova": "latest"
},
"peerDependencies": {
"@awesome-cordova-plugins/core": "^6.0.1",
"rxjs": "^5.5.0 || ^6.5.0 || ^7.3.0"
}
},
"node_modules/@babel/code-frame": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
@ -2461,6 +2475,11 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
},
"node_modules/com-darryncampbell-cordova-plugin-intent": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/com-darryncampbell-cordova-plugin-intent/-/com-darryncampbell-cordova-plugin-intent-2.2.0.tgz",
"integrity": "sha512-4ESoeYghE9GGuxKi4pnG+6CUJyYjS2j1tOmvlXXEM/9d5aBU47EpWbKKU1gjcfZFM4KCUbyba1NX6xNcH/L/wA=="
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",

View File

@ -28,6 +28,7 @@
"dependencies": {
"@awesome-cordova-plugins/android-full-screen": "^6.2.0",
"@awesome-cordova-plugins/geolocation": "^6.2.0",
"@awesome-cordova-plugins/web-intent": "^6.2.0",
"@capacitor-community/background-geolocation": "^1.2.6",
"@capacitor/android": "^3.4.3",
"@capacitor/core": "^3.4.3",
@ -39,6 +40,7 @@
"@suid/icons-material": "^0.5.1",
"@suid/material": "^0.8.1",
"@suid/vite-plugin": "^0.1.0",
"com-darryncampbell-cordova-plugin-intent": "^2.2.0",
"cordova-plugin-fullscreen": "^1.3.0",
"isomorphic-xml2js": "^0.1.3",
"lodash": "^4.17.21",

View File

@ -8,6 +8,29 @@ AndroidFullScreen.isImmersiveModeSupported()
.then(() => AndroidFullScreen.immersiveMode())
.catch(console.warn);
if (window.plugins) {
window.plugins.intentShim.registerBroadcastReceiver(
{
filterActions: ['android.intent.action.VIEW'],
},
function (intent: any) {
console.log({
caller: 'Intent broadcast receiver',
intent,
});
}
);
window.plugins.intentShim.onIntent(function (intent: any) {
console.log({ caller: 'Intent receiver', intent });
});
} else {
console.log({
caller: 'Intent',
message: "window.plugins doesn't exist",
window,
});
}
const App: Component = () => {
return (
<Routes>