Multiple page native flow using WL.NativePage.show? - ios

I have instrumented a native iOS application with the Worklight API's and it functions properly.
However, when I start with a Hybrid application and transition to native using WL.NativePage.show() I can only see the first native page. Buttons on that page are clickable but I am not sent to the next native page. I added [NativePage showWebView:returnedData] to one of the buttons and I am returned successfully to the hybrid app.
So my question is simply, once I go into native code I should be able to continue in native until I call the NativePage function, correct?
This is an iOS application on MFP 7.0 and when I click the native buttons I get no messages in the console.

WL.Nativepage.show is very limited and problematic when it comes to added more and more native functionality, esp if you add more classes and start interacting between them. That is because it is not properly set in the viewcontrollers stack.
It was meant to be a single page where you do native interaction only in it and no more.
Since you're using MFPF 7, you should have the Send Action API, which give you full control over what you'll be able to do when using native code in your Hybrid application.
You can see an example here: Integrating a Worklight-based iOS app with Xcode Storyboard
Read more about it here: Sending actions and data objects between JavaScript code and native code
Basically, after you send an action to the native layer of the application, you create your own classes (rather than use MFP's WL.NativePage.show API) and thus you control the entire flow.

Related

Call directly without extra dialog in iOS using Ionic 4

I'm trying to call a number from my app, but I want to do that without having to click on the modal that appears with "Cancel" and "Call" after I clicked my button in the app. Just click the button in the app and go straight to the call. Can I do that?
I already installed the native plugin [call-number] and the ionic package. It's working, it's making the call, It's just that I would like to make the call without that extra step.
Not sure if thats possible. Plugins provide communication between the ionic layer and the native layer so you are usually limited by the options the plugin gives you.
According to the documentation all you can do is bypass the choice of the calling app.
https://github.com/Rohfosho/CordovaCallNumberPlugin
You can't bypass that dialog. It is provided by iOS as an extra layer of protection for the user. It stops malicious apps initiating calls that may incur costs without user acknowledgement.

Show recaptcha in iOS native app from supremenewyork.com

I have an iOS app in which supremenewyork.com website is opened in web view. Sometime website shows one click recaptha (like when do payment).
My client wants to show the same recaptcha in the native app if it’s shown on website when user returns to the app. Is it possible?
If yes then how?
In theory, yes — this is entirely possible. You'll first want to get the data-sitekey by inspecting the page source that contains the CAPTCHA, after which you can use this repo this repo to get the initial implementation working in your iOS app (assuming by native you mean Swift).

Opening a website form in an (objective C) iOS app embedded browser, and then closing the browser upon submitting the form

Our web app has a certain complicated form that will take too long to build out as part of our native (Objective C) iOS app. I was hoping that we could instead open the form from the native app in an embedded browser (a browser built into our native app), and then upon submitting the form in the embedded browser, close the browser and return to a native app screen. Is this technically possible? If so, how can it be done?
If it isn't, then is the following possible? in the native app, have a button to open the form in a non-embedded browser (e.g., Safari), and then automatically close the browser when the form is submitted and return to the native app.
BTW, a co-worker told me that the former is possible with native Android (Java) apps.
Amin Negm-Awad's suggestion seems like the easiest option, but there's also the WebViewJavascriptBridge, to send messages back and forth from Objective-C and Javascript in a UIWebView, it might be worth checking out https://github.com/marcuswestin/WebViewJavascriptBridge
Haven't used it in a while, though.
(this feels like it'd be better as comment but I can't comment yet)
You can have a web view in your app displaying the form. Define an URL scheme for your app and send the form to the app:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW1
But you should really recheck, whether you want to use a web form inside your app.

Adding a Facebook log-in button in a hybrid Worklight app

I want to add a Facebook log-in button in a hybrid page in worklight and deploy it in iOS.
So far, we tried to add the log-in button in the hybrid part of worklight(js/html), but the button is not displayed, and the sdk is not called. We`re thinking that we cannot implement the Facebook log-in in the hybrid page and deploy it as a iOS hybrid app, since when we deployed it as a web application and run it in a mobile web browser it was fine.
We tried to implement the whole page as native, but the UI is a little different from our previous hybrid pages, we are thinking to add just the native Facebook log-in button in a hybrid page, the page consists of back button, header, buttons, labels, text-boxes,etc. The Facebook log-in button is located at the middle.
Can we implement this in worklight? or do you have any suggestions how to implement the facebook log-in button?
Any help would be greatly appreciated. Thank you.
Well, adding a UIButton into a Web View sounds not very possible to me.
What you could do instead, though, is make the button actually invoke a Cordova plug-in. The plug-in will implement -- in Objective-C -- the whole authentication flow you want, and when done return the control the Hybrid application.
If you're using Worklight 6.2, you can look at using the new Send Action API to easily transition between Worklight's ViewController (which embeds the Web View) to your ViewController (if you need one), or to just do some native code processing. I'm pretty sure you'll be able to create the desired experience this way.
Related reading:
Sending actions and data objects from JavaScript code to native code
Sending actions and data objects from native code to JavaScript code
Orientation issue with native pages in Worklight 6.2 and iOS7 (shows a quick implementation of Send Action, JavaScript)
Integration with Xcode Storyboard project (shows a quick implementation of Send Action, Objective-C)

Access code and data in hosting app using today extension

I'm wondering if it's at all possible to access features in the main app using a today extension in iOS 8. For example, can a media player send commands from its extension to the main app without opening the app (I know there is a framework for this but it's just an example)? The only solution I can see is using URIs but the problem is that it will open the app which isn't the behavior I'm looking for.
So for a complete example using the media player:
There is an extension in the today screen that allows you to play/pause using a button.
The user presses the button and the app plays/pauses in the background without leaving the notification center.
Any way to achieve this behavior?
Code can be shared using an embedded framework, however there are some backwards compatibility issues.
Data can be shared using shared user defaults.
Both are explained in the apple docs.

Resources