Are there any examples of invoking the BlackBerry 10 browser to open on an onclick event? I'm trying to do this with the native SDK using c++.
Thanks
HTML5
Taken from the sample here:
function openWebLink() {
// open web link - allows the system to choose an appropriate target that handles http://
blackberry.invoke.invoke({
uri: "http://www.blackberry.com"
}, onInvokeSuccess, onInvokeError);
}
function openWebLinkInBrowser() {
// open web link in browser
blackberry.invoke.invoke({
target: "sys.browser",
uri: "http://www.blackberry.com"
}, onInvokeSuccess, onInvokeError);
}
Native
Using the following attributes...
Cascades
An example is available here
Pure
Use navigator_invoke.h
navigator_invoke_invocation_t *invoke = NULL;
navigator_invoke_invocation_create(&invoke);
navigator_invoke_invocation_set_target(invoke, "sys.browser");
navigator_invoke_invocation_set_action(invoke, "bb.action.OPEN");
navigator_invoke_invocation_set_uri(invoke, "http://stackoverflow.com");
navigator_invoke_invocation_send(invoke);
navigator_invoke_invocation_destroy(invoke);
Include Qt library and call
Qt.openUrlExternally(targetUri);
Related
In Cordova you had immediate access to process.env.CORDOVA_PLATFORM is there something similar in Capacitor?
I'm looking to conditionally load some functions on startup and don’t want to block rendering waiting for async Device.getInfo to come back.
For example I want to determine immediately wether to import a script that make's native keyboard modifications, but I don't want to import this script if we are running on web
try {
const { Keyboard } = Plugins
Keyboard.setAccessoryBarVisible({ isVisible: true })
} catch (error) {
// Keyboard isn't available on web so we need to swallow the error
}
I'm using vue-cli
The answers so far are all correct, if you take a look into the Capacitors source code, there a few ways available, which can be used (but are undocumented for now):
Capacitor.getPlatform(); // -> 'web', 'ios' or 'android'
Capacitor.platform // -> 'web', 'ios' or 'android' (deprecated)
Capacitor.isNative // -> true or false
Be aware, that the method Capacitor.isPluginAvailable('PluginName'); only returns if the plugins is available or not (obviously) but important here, it does not tell you, if the method you want to execute after checking the availability is for your platform available.
The documentation of the Capacitor Plugins is not completed (yet).
Example (code), for the plugin StatusBar:
// Native StatusBar Plugin available
if (Capacitor.isPluginAvailable('StatusBar')) {
// Tint statusbar color
StatusBar.setBackgroundColor({
color: '#FF0000'
});
}
This would result in an error on iOS, since this method is not available there, on Android it works fine so far.
That means, that you need to implement a check of the Plugin and Platform combination by yourself (for now), may this will be improved in the future by Ionic / Capacitor itself.
Something like:
// Native StatusBar available
if (Capacitor.getPlatform() === 'android' && Capacitor.isPluginAvailable('StatusBar')) {
// Tint statusbar color
StatusBar.setBackgroundColor({
color: this.config.module.GYMY_MODAL_STATUSBAR_HEX_STRING
});
}
One more thing, you are not able to check, whether the method exists within this plugin (f. e. for the code above setBackgroundColor) as it is available, but throws an error (Error: not implemented) on a platform, which does not support it.
Hope I could help some of you guys.
Cheers
Unkn0wn0x
There is also the property Capacitor.isNative which you could use to determine whether the WebApp is running in Capacitor or in the Web.
https://github.com/ionic-team/capacitor/blob/master/core/src/definitions.ts
Update: In Capacitor V3 you can use Capacitor.isNativePlatform() for this.
https://capacitorjs.com/docs/v3/core-apis/web#isnativeplatform
As of Capacitor 3, you can use the following method to determine if it's running on a native device ("iOS" - "Android") or not ("web").
import { Capacitor } from '#capacitor/core';
if(Capacitor.isNativePlatform()) {
// Platform is mobile
} else {
// Platform is not mobile
}
Official documentation link. https://capacitorjs.com/docs/core-apis/web#isnativeplatform
Found it undocumented: Capacitor.platform
Capacitor.platform could be for example web ios android
Also if you wanted to know if you were running native before loading Capacitor, i.e you wanted to reduce bundle size by not including Capacitor on the web.
window.origin.includes('capacitor://')
You can now use Capacitor.isPluginAvailable('plugin name') to make this check, e.g., :
import { Capacitor, Plugins } from '#capacitor/core';
const { Keyboard } = Plugins;
...
const isAvailable = Capacitor.isPluginAvailable('Keyboard');
if (isAvailable) {
Keyboard.setAccessoryBarVisible({ isVisible: true })
}
You can see all of those on official doc here: https://capacitorjs.com/docs/basics/utilities#getplatform
if (Capacitor.getPlatform() === 'ios') {
// do something
}
if (Capacitor.isNative) {
// do something
}
I would say Device.getInfo() is the only reliable way of checking device's platform in capacitor based project.
Because the implementation of getPlatform(), Capacitor.platform is based on user agent of ui client. That means, if you opened your app on web and select developer tools then select mobile view, in this case it identify your platform as ios or android depending on which one you selected in dev tools instead of 'web'
I am importing the Wizcorp phonegap-facebook-plugin using the intelxdk.config.additions.xml file with this code:
<intelxdk:plugin intelxdk:name="com.phonegap.plugins.facebookconnect" intelxdk:value="https://github.com/Wizcorp/phonegap-facebook-plugin/">
<intelxdk:param intelxdk:name="APP_ID" intelxdk:value="MyActualAppID" />
<intelxdk:param intelxdk:name="APP_NAME" intelxdk:value="fizz points" />
</intelxdk:plugin>
I've read and understand that I will not be able to test this 3rd party plugin in the emulator, or via the test or debug tabs, so I've created a test build for Android.
Based on the documentation, I believe I am supposed to reference this API via calls to the facebookConnectPlugin, such as:
facebookConnectPlugin.login(["publish_stream", "publish_actions", "offline_access"],
fbLoginSuccess,
function (error) { alert("There was an error: " + error) });
However, I know that in the built app, as in the emulator, the facebookConnectPlugin is not defined, because I get an alert based on the following block:
if (typeof facebookConnectPlugin != 'undefined'){
// do stuff
} else {
alert("FacebookConnectPlugin Not Defined");
}
I assume this is because I need to include the 3rd party library in my code in addition to including it in my project where suggested by the helpful comments, something like:
<!-- Most third-party libraries should go here. References (below) are just examples to give you the general idea... -->
<!-- <script src="lib/mc/hammer.js"></script> -->
Initially, I didn't know the path where the 3rd party library is ultimately located in the package after the build tool retrieves it. But I was told that I could change the .apk extension to .zip extract and explore the contents.
I did this, and found that the library was stored in:
www/plugins/com.phonegap.plugins.facebookconnect/www/phonegap/plugin/facebookConnectPlugin/facebookConnectPlugin.js
So I added the following to my index.html file:
<script src="plugins/com.phonegap.plugins.facebookconnect/www/phonegap/plugin/facebookConnectPlugin/facebookConnectPlugin.js"></script>
However, when built, my test to see if the FacebookConnectPlugin is defined still fails.
Thanks!
Noah
[I've essentially asked the same question on the Intel forums here: https://software.intel.com/en-us/forums/topic/536743 . No solution yet, but if I get one I will post it here.]
You need to build your app and install it on your device to test the WizCorp Facebook plugin. Please make sure you follow the instructions for configuring your app on Facebook.
note the Emulator (simulator) does not support third party plugins as you have noted. Same for using App Preview to test. You must build your app in the cloud.
thanks,
Ian
Are you accessing the facebookConnectPlugin object from inside device ready event?
document.addEventListener("intel.xdk.device.ready",function() {
// try in here
}, false);
It could be undefined if you are accessing it from outside as the plugin is not ready to be used yet.
I would like to open a URL in private mode from a Thunderbird extension. Right now, the following code works in "standard" non-private mode:
try {
var eps = Components.classes["#mozilla.org/uriloader/external-protocol-service;1"].
getService(Components.interfaces.nsIExternalProtocolService);
var ios = Components.classes["#mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
eps.loadURI(ios.newURI("http://www.example.com", null, null));
} catch (err) {}
Any idea how to achieve the same result in private mode? I'm interested to make it work with launching Chrome as the default browser. (Once again, Chrome is correctly launched with the code above).
You cannot really launch Firefox with a new url in a private window AFAIK. -private-window <url> will open a new private window, but still put the new tab in a regular one.
Chrome can be launched with chrome --incognito <url>, however you would need to launch it yourself via nsIProcess and therefore would first have to figure out where the chrome binary is.
If you can guarantee that the default handler is Chrome, then you might use nsIExternalProtocolService.getProtocolHandlerInfo(), use preferredApplicationHandler and QueryInterface that to nsILocalHandlerApp to find the .executable. Otherwise, you'll have to deal with the OS and/or known paths yourself.
Hi
I have some appliacation written in GWT 2.2 (tested also on previuos versions) with file upload. Basicly there is FileUpload component with Struts servlet on server side. The problem is that it works fine on IE and FF, but does not work on Chrome and Opera.
I found some tip to use gwtupload library ( i build the simplest case ) and the problem still occurs... With gwtupload I get alert with:
"Error, your browser has not sent any information. Please try again or try it using another browser"
Simple code for gwtupload version:
defaultUploader = new SingleUploader();
verticalPanel.add(defaultUploader);
defaultUploader.addOnFinishUploadHandler(onFinishUploaderHandler);
// Load the image in the document and in the case of success attach it to the viewer
private IUploader.OnFinishUploaderHandler onFinishUploaderHandler = new IUploader.OnFinishUploaderHandler() {
public void onFinish(IUploader uploader) {
if (uploader.getStatus() == IUploadStatus.Status.SUCCESS) {
//new PreloadedImage(uploader.fileUrl(), showImage);
// The server can send information to the client.
// You can parse this information using XML or JSON libraries
// Document doc = XMLParser.parse(uploader.getServerResponse());
// String size = IUploader.Utils.getXmlNodeValue(doc, "file-1-size");
// String type = IUploader.Utils.getXmlNodeValue(doc, "file-1-type");
Window.alert("Upload work");
}
}
};
Deafult servlet on the serves side.
Again, it works only on FF and IE. I hope somebody faced similar problem. :)
It could be some nasty WebKit bug. I think to remember something about a problem uploading files with WebKit-based browsers on OS X. You may want to check the WebKit bug database.
I am developing a map application for iPhone.I am using google maps API to develop this,by adding the java script file to the resource.My problem is that I need to catch an event defined in the java script. for eg: I need to cath the following event in java script
"GEvent.addListener(poly, "click", function(latlng, index)" .
Please anyone help me.
Thanks in advance
Why are you not using MapKit? Is this a web app only?
You can call javascript to probe if something has happened, but you cannot have javascript call back to your code... at least not directly. You can override the URL handling and have javascript included that tries to make an external call that your code recognizes and acts on.