BrowserField Blackberry - blackberry

We are writing a blackberry applciation which has social media integration, we are able to invoke the browser using BrowserSession and call the facebook link with the sharer link
http://m.facebook.com/?sharer= , this works perfectly fine , however we have encountered a new method where we could embed the HTML page inside the application screen using Browserfield , unfortunately this library is available only post 5.0
I have some links which indicate that we may be able to use pre-processing directive to detect the version and build the library accordingly , to be specific
ifdef version_5.0_and_above
/* Use BrowserField */
else
/Invoke Browser/
Can someone shed some light on how this can be achieved?
Thanks for all the help in advance

This RIM doc explains how to use preprocessing.
Basically you'll have to create 2 projects with almost the same code. The difference is just in the code that implements your browser actions. For one project you assign a label (preprocessing statement) "OS_5_OR_ABOVE" and use the API 5+, the other project may be left unlabeled (since there are only 2 projects) and it should use API 4.7.0 (or the lowest API your app supports).
A sample code with preprocessing would be:
//#preprocess
package ...
import ...
public MyClass {
public MyClass() {
//#ifdef OS_5_OR_ABOVE
/* this is only called for the OS_5_OR_ABOVE project */
//#else
/* this is only called for the second project */
//#endif
}
}
Definitelly you'll need to compile each project using different JDE (for instance, JDE 5.0 and JDE 4.7.0).
Note you can also use preprocessing for conditional imports. However I'd not recommend this, since it is very easy to break the code in Eclipse on code auto-format/cleanup action.

Related

How do I migrate a legacy XPCOM extension to WebExtensions?

Embedded WebExtensions talks all about how to "... embed a WebExtension in a classic bootstrapped extension or an Add-on SDK add-on."
But I've got neither a "bootstrapped" nor "Add-on SDK" extension, just a decade old plain old XPCOM/overlay extension. I don't have a bootstrap.js to have a startup, nor do I use the Add-on SDK for whatever it does.
I tried adding
<em:bootstrap>true</em:bootstrap>
But all that accomplishes is completely destroying the extension, it only loads that (empty) new bootstrap.js file.
Indeed, I want to migrate: The data that my classic extension has needs to be exported to the webext version, for good user experience.
At our tracking bug a user has posted a helpful link:
https://github.com/mdn/webextensions-examples/tree/master/embedded-webextension-overlay
Which boils down to
const {
LegacyExtensionsUtils,
} = Components.utils.import("resource://gre/modules/LegacyExtensionsUtils.jsm");
const myOverlayEmbeddedWebExtension = LegacyExtensionsUtils.getEmbeddedExtensionFor({
id: addonId, resourceURI: baseURI,
});
myOverlayEmbeddedWebExtension.startup().then(({browser}) => {
dump(`${addonId} - embedded webext started\n`);
browser.runtime.onMessage.addListener(msg => {
dump(`${addonId} - received message from embedded webext ${msg}\n`);
});
}).catch(err => {
Components.utils.reportError(
`${addonId} - embedded webext startup failed: ${err.message} ${err.stack}\n`
);
});
Which is surely the equivalent of what the bootstrap/SDK code is doing for you.
You can only rewrite it from scratch using the WebExtension APIs.
Note that the WebExtensions model requires you only use the APIs explicitly exported for use by extensions, so prepare to drop some features during the rewrite, or even to find that it's impossible to reimplement the extension altogether (unless you convince Mozilla to implement the new APIs you need or implement it yourself in a WebExtension Experiment -- still limited to Nightly/Dev.edition).
See Porting a legacy Firefox extension
[edit] the "embedded WebExtension" does indeed require your "outer" extension to be bootstrapped or Add-on SDK-based (so no "classic" extensions), but it was only intended to be used for gradual migration and will not work in Firefox 57.
One option that I suggest to the people in similar situations, is to provide an Export function in the current legacy addon and an Import in the WebExtension version. While it is not an automatic migration (has to be user action), it overcomes some of the limitations of the WebExtension local-file access.
Using the Export, users will be prompted to save their complete data to hard-disk.
Then the next upgrade which would be a WebExtension, prompts the users to Import the saved data.

Can I use Zebble for only UI and use Xamarin for everything else

I would like to use Zebble only for producing UI and all other things I would like to use Xamarin apis/custom http apis/local db or whatever it may be. Basically a UI project with zebble and other things will be in PCLs.
Will it be compatible? Could you please advice?
Yes you can. There is nothing in Zebble that prevents you from using the native APIs directly.
For custom http calls, I recommend using the HttpClient class which is by default available in all 3 platforms of a newly created Zebble project.
For Device APIs, you can of course use the standard API classes of each platform, but to save time and achieve 100% code reuse I strongly recommend using the http://zebble.net/docs/device-api. For example if you want o use the lamp (aka flash, led or torch) you can very easily implement that on all platforms with very little code code:
// Determines if a lamp feature is available on the device.
if (await Device.Torch.IsAvailable()) { ... }
// This will switch the lamp on.
await Device.Torch.TurnOn();
// This will switch the lamp off.
await Device.Torch.TurnOff();

Cordova white screen of death iOS - browserify, react, cordova

I have a strange situation with a project for iOS.
Its created using browserify and React for Cordova and aimed at iOS.
We have built the project for iOS using Cordova commands without any issues. It runs with no xcode errors or Javascript errors either however none of the JS ui appears on screen. We just get a blank white screen with the system bar at the top. See attached screen shot.
So far we have found out that if you add HTML to the index.html in WWW folder it prints that fine so I assume its the JS.
When we run in a browser it works as well as building for Android.
We have no problems with anything other than iOS (simulator and device build).
hopefully someone can help me out here because I'm stumped. Please let me know what files you need to look at and I'll make them available.
Thanks in advance.
IMAGES
The error screen: http://www.voidapplications.co.uk/errorScreen.png
What we expect to be shown: http://www.voidapplications.co.uk/whatWeExpect.png
If you are using internationalization component that's because you need to use the Intl polyfill:
Intl.js and FT Polyfill Service
Intl.js polyfill was recently added to the Polyfill service, which is developed and maintained by a community of contributors led by a team at the Financial Times. It is available thru cdn.polyfill.io domain, which routes traffic through Fastly, which makes it available with global high availability and superb performance no matter where your users are.
To use the Intl polyfill thru the Polyfill service just add one script tag in your page before you load or parse your own JavaScript:
<script src="https://cdn.polyfill.io/v1/polyfill.min.jsfeatures=Intl.~locale.en"></script>
When specifying the features to use thru the polyfill service, you have to specify what locale, or locales to load along with the Intl polyfill for the page to function, in the example above we are specifying Intl.~locale.en, which means only en, but you could do something like this:
<script src="https://cdn.polyfill.io/v1/polyfill.min.js?features=Intl.~locale.fr,Intl.~locale.pt"></script>
note: the example above will load the polyfill with two locale data set, fr and pt.
This is by far the best option to use the Intl polyfill since it will only load the polyfill code and the corresponding locale data when it is really needed (e.g.: safari will get the code and patch the runtime while chrome will get an empty script tag).
source & other ways to include Intl polyfill: https://github.com/andyearnshaw/Intl.js#getting-started
You can debug the UIWebView in the simulator with Safari http://moduscreate.com/enable-remote-web-inspector-in-ios-6/. You'll probably see a big error message in the console, if not you will have access to the debugger so you can step through and sort it out.
I have had this issue in the past, it turned out to be unsupported javascript features. for example, setting default parameters in the function. I.e:
function test( myvalue=0 ) { /* ... */ };
I had to initialise the value inside the function instead. You could also try removing any ecma script 2016 features you may have implemented.
Trouble shooting this type of issue was painful. I created a minimal version of the smallest part of my product compiled and ran it on ios emulator, added another chunk of the product, rinse and repeat.
Im sure there's a better way to detect these issues, but I do not know it.

IBM Worklight 5.0.6 - How to globalise system messages

I am trying to enable the system messages translation option but it is failing in my project.
In my main page js file i declare the following code globally
WL.ClientMessages.loading = "Custom loading";
function wlCommonInit(){
var locale = WL.App.getDeviceLocale();
var lang = WL.App.getDeviceLanguage();
if (locale.indexOf("en")!=-1) languageChanged("english");
if (locale.indexOf("fr")!=-1) languageChanged("french");
if (locale.indexOf("ru")!=-1) languageChanged("russian");
if (locale.indexOf("he")!=-1) languageChanged("hebrew")
}
This is hw to globalise the application strings but i have small doubts are
1. wt is system strings
2. How to translate the it
i have gone through the docs but not clear to me pls help me out
This snippet is not enough... it doesn't show exactly what you're doing in your app.
Please follow the Enabling Translation training module for the proper steps to make.
There is also an example project that shows you how it is done. Compare it with yours.
Translation of native components (like the busy indicator) based on the system locale will be available in a future release.
In Worklight 5.0.6, the first busy indicator you see is controlled by Worklight and you cannot translate it. To overcome this, set connectOnStartup to 'false' and create your own busy indicator. You can then translate its message as described in the module.
Please go over the IBM Worklight Getting Started materials to familiarize yourself with the Worklight platform.

How to load Html in Browser field for Blackberry Os version 4.6.1.310 i

public BrowserFieldDemoScreen()
{
BrowserField mybroBrowserField=new BrowserField();
add(mybroBrowserField);
mybroBrowserField.displayContent("
<html><body><h1>hello world! This blackbery apps
</h1></body></html>", "http://localhost");
}
I'm new in Blackberry application development, I have load html in browser and I have write code for that it works perfectly for more than OS version 5.
But I have create app for 4.6.1.310 model number 8900 not working giveing some uncaught Exception. Please tell me what I have to change so that it should work on 4.6.1.310 version also,
You cannot use BrowserField class below Blackberry OS 5.0
Before running application go through sdk docs.
The BlackBerry Facebook SDK was written to use embedded browser functionality, before (5.0) BrowserField was available. I believe that code is free to use and modify to your needs.
see the project here
Look in the sample code (scroll down the page) at his LoginScreen class.
You should be able to modify that class to serve your purposes. This particular class, of course, has a hardcoded URL that points to Facebook. You will obviously change that to accept whatever URLs you like, and remove other references to facebook classes you don't need. You will definitely need more than just the LoginScreen class, but all its dependencies should be available on that site.
Post a comment if there's any problems getting this to work. I have some other legacy code that does this successfully, but I'm not free to post it ... but quickly looking at the Baskoro code I linked to appears like it does basically the same thing.

Resources