Hi.
I’m not able to use the example “Web Sharing - NSB App Studio” for use of the “Intent” does not work within NsB/AppStudio in VB. Is there any working example in NSB/AppStudio?
Hi.
I’m not able to use the example “Web Sharing - NSB App Studio” for use of the “Intent” does not work within NsB/AppStudio in VB. Is there any working example in NSB/AppStudio?
You might have to add some entries to your config.xml. Have a look at Cordova’s docs for allow-intent.
I’ll try again!
My config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<widget
xmlns = "https://www.w3.org/ns/widgets"
id = "com.nsbasic.{id}"
versionCode = "{phoneGapBuildCounter}"
version = "{version}">
<name>{title}</name>
<description>{description}</description>
<icon src='{icon}' />
<preference name='SplashScreenDelay' value='2000' />
<preference name='AutoHideSplashScreen' value='true' />
<plugin name='cordova-plugin-splashscreen' source='npm' />
<preference name="permissions" value="none"/>
<!-- sample preference specifications -->
<!-- <preference name="autorotate" value="false" readonly="true"/> -->
<!-- <preference name="orientation" value="default" /> -->
<!-- <preference name="fullscreen" value="true" /> -->
<!-- Allow images, xhrs, etc. to google.com -->
<access origin="http://google.com" />
<access origin="https://google.com" />
<!-- Access to the subdomain maps.google.com -->
<access origin="http://maps.google.com" />
<!-- Access to all the subdomains on google.com -->
<access origin="http://*.google.com" />
<!-- Enable requests to content: URLs -->
<access origin="content:///*" />
<!-- Don't block any requests -->
<access origin="*" />
<!-- Allow links to example.com -->
<allow-navigation href="http://example.com/*" />
<!-- Wildcards are allowed for the protocol, as a prefix
to the host, or as a suffix to the path -->
<allow-navigation href="*://*.example.com/*" />
<!--
A wildcard can be used to allow the entire network, over HTTP and HTTPS.
This is *NOT RECOMMENDED*
-->
<allow-navigation href="*" />
<!-- The above is equivalent to these three declarations -->
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<!-- Allow links to web pages to open in a browser -->
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<!-- Allow links to example.com to open in a browser -->
<allow-intent href="http://example.com/*" />
<!-- Wildcards are allowed for the protocol, as a prefix
to the host, or as a suffix to the path -->
<allow-intent href="*://*.example.com/*" />
<!-- Allow SMS links to open messaging app -->
<allow-intent href="sms:*" />
<!-- Allow tel: links to open the dialer -->
<allow-intent href="tel:*" />
<!-- Allow geo: links to open maps -->
<allow-intent href="geo:*" />
<plugin name="cordova-plugin-statusbar" source="npm" />
<preference name="StatusBarOverlaysWebView" value="{phoneGapStatusBarOverlay}" />
<preference name="StatusBarBackgroundColor" value="{phoneGapStatusBarColor}" />
<preference name="StatusBarStyle" value="{phoneGapStatusBarStyle}" />
<plugin name="cordova-plugin-whitelist" source="npm" />
<allow-navigation href="*" />
<access origin="*" />
<allow-intent href="*" />
<plugin name="cordova-plugin-btprinter" source="npm" />
<plugin name="cordova-plugin-inappbrowser" source="npm" />
<plugin name="cordova-custom-config" source="npm"/>
<plugin name="cordova-plugin-intent" source="npm"/>
<config-file target="AndroidManifest.xml" parent="./application/activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.*" />
</intent-filter>
</config-file>
<plugin name="com.agorapulse.cordova.openwith" source="npm">
<variable name="IOS_URL_SCHEME" value="cordovaopenwith" />
<variable name="DISPLAY_NAME" value="gluconet" />
<variable name="ANDROID_MIME_TYPE" value="*/*" />
<variable name="ANDROID_EXTRA_ACTIONS" value="<action android:name="android.intent.action.SENDTO"/> <action android:name="android.intent.action.MAILTO"/><action android:name="android.intent.action.VIEW"/>"/>
</plugin>
</widget>
This is my global scope:
function Main()
document.addEventListener("deviceready", setupOpenwith, False);
End function
This is the function copied from (Web Sharing) with some changes! Created in the wIntent.js file
function setupOpenwith() {
// Increase verbosity if you need more logs
//cordova.openwith.setVerbosity(cordova.openwith.DEBUG);
// Initialize the plugin
cordova.openwith.init(initSuccess, initError);
function initSuccess() { window.alert('init success!'); }
function initError(err) { window.alert('init failed: ' + err); }
// Define your file handler
window.alert('add Handler!')
cordova.openwith.addHandler(myHandler);
function myHandler(intent) {
window.alert('intent received');
window.alert (' action: ' + intent.action); // type of action requested by the user
window.alert (' exit: ' + intent.exit); // if true, you should exit the app after processing
for (var i = 0; i < intent.items.length; ++i) {
var item = intent.items[i];
window.alert (' type: ', item.type); // mime type
window.alert (' uri: ', item.uri); // uri to the file, probably NOT a web uri
// some optional additional info
window.alert (' text: ', item.text); // text to share alongside the item, iOS only
window.alert (' name: ', item.name); // suggested name of the image, iOS 11+ only
window.alert (' utis: ', item.utis);
window.alert (' path: ', item.path); // path on the device, generally undefined
}
if (intent.items.length > 0) {
cordova.openwith.load(intent.items[0], function(data, item) {
// Note that there is no need to wait for the upload to finish,
// the app can continue while in background.
if (intent.exit) { cordova.openwith.exit(); }
});
}
else {
if (intent.exit) { cordova.openwith.exit(); }
}
}
}
Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)
OK thanks.
Has anyone done something similar and have any tips? I can’t get this to work! Help.
Websharing is VERY ugly and VERY difficult to get to work. I have a project that’s sitting on the front burner just simmering because of this very issue.
There are plugins that work for Android and will get you on the share menu and pass in the appropriate data when your app is selected. When it comes to iOS this is a much more difficult process and most of the suggested methods involves building locally which is it’s own mess.
The last time I asked for help with this very issue on the cordova Slack channel I was told to use this plugin and was warned that it was VERY difficult to get it to work.
For other intents, like opening my app via a link within an email, I have found this plugin to work:
<!-- This plugin allows us to link to our app from an email on the same device. -->
<plugin name="cordova-plugin-customurlscheme" source="npm">
Thanks for the answer!
Maybe I’m going the wrong way! I actually need to call or another app from within mine!
It would look something like this below, but unfortunately I’m not getting it on the NSB.
"
Intent intentSitef = new Intent("br.com.softwareexpress.sitef.msitef.ACTIVITY_CLISITEF");
intentSitef.PutExtra("empresaSitef", "00000000");
intentSitef.PutExtra("enderecoSitef", ip);
intentSitef.PutExtra("operador", "0001");
intentSitef.PutExtra("data", "20200324");
intentSitef.PutExtra("hora", "130358");
intentSitef.PutExtra("numeroCupom", op);
intentSitef.PutExtra("valor", valor.toString().Replace(",", "").Replace(".", ""));
intentSitef.PutExtra("CNPJ_CPF", "03654119000176");
intentSitef.PutExtra("comExterna", "0");
intentSitef.PutExtra("modalidade", "114");
intentSitef.PutExtra("isDoubleValidation", "0");
intentSitef.PutExtra("caminhoCertificadoCA", "ca_cert_perm");
((Activity)Forms.Context).StartActivityForResult(intentSitef, REQ_CODE_MSITEF);
I believe the problem is not being able to pass the “Intent”. I’m using Websharing as an example, but it doesn’t even work.
The other app must have an “intent listener” otherwise your intent calls fall on deaf ears. Give the openwith plug-in a look.
Hi!. The other app has “intent listener” and works with the above model in another language, actually I’m not able to pass the “intent” on the NSB, I’ve looked for an example and tested it in all ways, but I still couldn’t make it work.
Yeah, that sounds like something that’s an @ghenne issue.
What language is the other app in?
We’ve been silent on this issue because it’s outside of our expertise. AppStudio exposes the JavaScript environment to you. We’re very interested in addressing issues with that. However, there is a lot which can be done with JavaScript itself: we can’t provide support for programming in general.
I can’t tell you what the language of the other app is! But I’m not being able to pass the “Intent” nor in the web test application "“Web Sharing - NSB App Studio” that I found at Web Sharing - NSB App Studio
If this example worked then I would try with the application I need to access.
That tech note applies to apps running as a web app. If you’re compiling into a native app, the rules all change.
Is there any example of calling an app by another using “Intent” in NSB/Appstudio with Cordova? it can be something very simple.
do you have an answer
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.