IBM Worklight - How to hide the HTML page in a Hybrid app and load native page instead? - ibm-mobilefirst

I am developing a hybrid app and my first page is native page in both android and ios. I kept initial html page as blank white background and loading native page by using the WL.nativePage.show API method.
I am able to go to native page but after the splash screen, it's showing a white screen which is my HTML page for a while then the native pages is displayed. So I want to avoid that white screen. How to do that?
My code for showing native is:
function wlCommonInit() {
WL.NativePage.show('ProductHomeViewController', backFromNativePage, params);
}

This is not easily doable in Worklight 6.1, but is likely to be improved in a later release.
In Android, you can change in AndroidManifest.xml the default activity the application starts with that of yours (the activity you have created for your Native Page)
In iOS, you can start another UIViewController from CDVMainViewController
The above will help to have a Hybrid app that its "start page" (the page you see after the splash image) is a native page, HOWEVER, this will not help in sharing the session between the Hybrid and Native pages (as explained in the answer to this question by you).
There is work in progress to create a Cordova plug-in that will allow session sharing between hybrid and native pages when the native page is the starting page of the application; it is not yet ready. As I wrote at the top, in a future release all of this should work better.
To address the questions in the comments:
The Hybrid application also contains that same Native API as a Native application would, this means that once you launch the app and navigate to a native page after the splash image (based on the above), you can still use the same native API methods to connect to the Worklight Server, invoke Worklight Adapters, etc.
The problem is still the sharing of the cookies (session) between the native webview and the hybrid webview.
Again, as written above, there is work in progress to create a Cordova plug-in that will allow session sharing between hybrid and native pages when the native page is the starting page of the application; it is not yet ready. In a future release all of this should work better.

Related

OneSignal React Native Push iOS Universal Linking (avoid WebView)

Using onesignal, When one sets the push notification value "url" for a notificaiton to open in an app, aka universal linking, by default the app is opened and a webview screen emerges (not on android, only iOS - at least in React Native).
I want to ignore this webview. I don't want to open it. The url is supposed to open the app to the corresponding universal link/deep link, not my domain on a web broswer. If I click on a similar link from a non-notificaiton source, it takes me to the screen, why does the push notification not do this?
How do I override this? I can't seem to figure it out. Do I have to manually implement this? Why does it open a webview by default and not the corresponding screen in the app instead?
It seems you have to manually route it if one were to go this route, unfortunately. From what I'm gathering bits here and there.
this is a bad choice to go with if you're using iOS:
https://www.myapp.com/p/fdsafa
this is better:
myapp://p/fdsafa
unfortunately onesignal has it setup in some weird way with the https://www.myapp.com that it makes it useless on iOS, unless your actual intention is to open an actual web url in a webview. Where as myapp:// is compatible with both platforms (just don't put a host on Android, leave the host out, just do the myapp as the schema). Works.

Windows 8 app load web app from url

I've developed an Android app who loads a web app from an url in fullscreen and caches it with application cache. That works fine, so I would do the same for Windows 8. Is this possible? How it's done?
To load any WebSite/WebApp in your windows-8 app, you can add WebView control in your ApplicationPage.
You can find more details/Information regarding WebView control here
and find Code samples for Adding WebView in your app here
For detailed answer, you have to elaborate your question more.

IBM Worklight 6.1 - White screen while reloading the app

I have developed a Worklight application in Dojo for BlackBerry OS 10.
When I click the "Reload" button, the WL.Client.reloadApp() API method is invoked.
The app gets reloaded with white screen.
I have attached the screenshots which will explain the issue.
IMO this is the expected behavior.
When using WL.Client.reloadApp() you essentially request to reload the web resources of the application; you can't expect to both show them and reload them at the same time. Thus, this is the expected behavior and the same will also happen when previewing via Worklight Console's MBS (I've checked that).
A question to ask is, why would you want to have such a button in your application to reload the app... Your scenario is unclear to me.
What you can do perhaps, is display some image while reloading using the Cordova Splashscreen API. Something like this:
function reload() {
navigator.splashscreen.show();
WL.Client.reloadApp();
}
This way when executing this function a splash will be displayed, masking the "white screen".
Next, after the app inits, you'll need to remove the splash...
So in wlCommonInit() you'll do:
function wlCommonInit() {
navigator.splashscreen.hide();
...
...
}
This should not interfere with the splash image shown by the Worklight framework upon application startup.
Try it.

How to do FB feed share post without leaving my hybrid app?

I am making mobile app using Sencha touch which will be bundled as native app and installed on devices. In my app on certain pages I want to add "share" functionality which is supposed to post some data to user's feed. While testing on browser I can to do that by opening a window with FB sharing url like "https://m.facebook.com/dialog/feed" or "https://m.facebook.com/sharer.php" and passing all related params as explained in https://developers.facebook.com/docs/reference/dialogs/feed/
But when this app is bundled and I share with this, user is moved to browser and cannot return to app because redirect_uri cannot point to app which is why I wanted to open this dialog within my app, probably in an iFrame. This is also not possible because these dialogs are not allowed to be embedded in iframe by META tags and in order to surpass it I have to do user login which again is another dialog which I cannot open in my app's iFrame.
I also looked at sample sencha app http://blooming-day-7830.herokuapp.com/ but it also takes user to separate login page instead of opening in-app dialog.
So my questions is how does hybrid apps connect with FB without moving out user to browser?
if you decide to use PhoneGap you can try the following two options. You will have to check for the iOS version before you switch your Phonegap call to. . .
Option 1 : for iOS before 6.0
Phonegap has a pretty nifty ChildBrowser plugin that you can use to load the FB share page without leaving the app for iOS 5.0 and below.
Option 2 : for iOS 6.0+
Facebook Share functionality has now been added to iOS. So all you have to do, is call a custom plugin class that you create, and call the standard FB share code using a basic Phonegap plugin call. You won't leave the app, the ChildBrowser doesn't have to show up, instead, you'll get the stock iOS-FB share sheet that will show up, you can add pictures, text, and so on, and post to facebook.

iOS App & jQuery Mobile Site - Include JS file ONLY if page is viewed in native iPhone app

I have a mobile website built using jQuery Mobile. I am currently designing an iOS native app with a single webView to display this mobile website.
PROBLEM:
If the jQuery mobile webpage is viewed in a normal mobile browser, I want all to function normally. BUT if the webpage is viewed using the webView in the iPhone app (not Safari.app) I am designing, I want to include an additional line of code on the webpage to pull in some custom JS.
Here's what I want to be added to the page ONLY IF viewed inside of my iPhone app's webView:
<script type="text/javascript" src="http://www.example.com/mobile/js/custom-jqm-defaults.js"></script>
This code needs to be pulled in (according to the jQuery mobile docs) before jQuery Mobile is loaded. Is this possible? And if so, could you point me in the right direction and give me some code?
EDIT
I found this link whereby Facebook detects if they are being viewed WITHIN an app. Is there another way to do this obviously NOT using the FB API? Here is their code:
if (FB.UA.nativeApp()) {
// Hide your credits stuff
}
You can change the user agent in your NSURLRequest, and then check for that agent on your server.
Changing it app-side is easy.