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

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.

Related

opening an Instant App by a Firebase Dynamic Link with custom parameters (App Links)

I'm searching for a way to open an Android Instant app in a mobile browser.
The app supports app links (deep linking in http/https).
My Android app is working as an instant app and can be opened by an app link in different apps that are not browsers (Gmail, Whatsapp, etc.).
I have concluded that the only way to be able to have an instant experience in browser apps is by using Firebase Dynamic Links.
The only way it works is by using short Firebase Dynamic Links (without app parameters in the link). I need to be able to build the link manually with parameters, so the app will know it's desired actions.
In order to use Firebase Dynamic Links, I've:
set up all basic requirements in my app for Firebase Dynamic Links.
set up a sub-domain and enabled it in the Firebase console (the Hosting section).
created a long dynamic link manually (described as the only way to send parameters by link).
example:
https://sub.example.com/?link=https://example.com/some-path/file?param1=value1&param2=value2&apn=package.name.com
This long link works (in mobile browsers) only if the app is installed / is in cache.
If the app is not installed, the app's play store page opens and offers to install / try it (as instant app).
I've contacted Firebase support, and got a solution:
Adding the "afl" parameter in the link with the value of the app link.
Example:
https://sub.example.com/?link=https://example.com/some-path/file?param1=value1&param2=value2&apn=package.name.com**&afl=https://example.com/some-path/file?param1=value1&param2=value2**
The Android app links work properly if the user follows the following steps:
Verify that you are logged into Google, Chrome, and Google play with the account you plan to use for the instant apps.
Go into Google Play Store settings, find the tab for Instant Apps and Enable Instant Apps enable Instant Apps
In your website add html to index.html or the equivalent file where you want to place the embedded link such as this:
<!DOCTYPE html>
<html>
<body>
<h2>HTML Links</h2>
<p>HTML links are defined with the a tag:</p>
This is a link to the instant app </body>
</html>
The instant app linking will only work from links embedded within an app such as in gmail or Chrome and not from directly pasting the url in a browser navigation bar.
If you have any questions about this approach, please let me know.

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 - How to hide the HTML page in a Hybrid app and load native page instead?

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.

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.

How does new Facebook App integrates App Store page?

Since some weeks Facebook displays ads for apps in their iOS client. When you click on them the App Store apps detail page opens as a modal view controller inside the Facebook app.
I only know how do open App Store pages via their URL, but how to show a App Store page from inside your app?
You're looking for the SKStoreProductViewController. Here is a link to the docs :)
https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKITunesProductViewController_Ref/SKStoreProductViewController.html
I also found this helpful tutorial :)
http://www.techotopia.com/index.php/Making_Store_Purchases_with_the_SKStoreProductViewController_Class