Send Events to Webview - ios

I am trying to do send touch events to UIWebview remotely. I am trying to achieve something like LogMeIn app, where once remote is taken, the remote user can perform clicks/selection and scroll web-view on the user iPhone. I read through many links, but all are suggesting to use private api as you can't create touch events. If i use private api's then the app will get rejected from appstore.

use below URL to make call to functions from webview.
http://ramkulkarni.com/blog/framework-for-interacting-with-embedded-webview-in-ios-application/
In this delegate file
- (id) processFunctionFromJS:(NSString *) name withArgs:(NSArray*) args error:(NSError **) error
method is there to get event of button click on webview.

Related

How do I embed my app commands with siri or any other voice activation library

Basically, I want my app to be voice activated
If user asks my app to open then it should open
if the user says something it has to be typed in the textbox
if the user says to click on a button it has to be done
if the user wants to be voice read then it should read it out.
basically, I would like to read the user command sometimes if possible in the app and serve my user base the best
There is no much documentation available there,,, so I thought of asking the question here
This is not possible. You cannot use Siri with apps for anything else than what is implemented in the SiriKit framework and SiriKit does not provide any methods for just opening your app without actually handling an intent and custom commands are also not supported at the moment.
For dictation you can use the Speech framework and for the system to "read out" something from your UI, you need to support VoiceOver, which is part of Accessibility.
My purpose is to open secret screen (test screen) into my app. Best way is to display a normally hidden button, I use a fake messaging with Siri. App is ok for Siri request but no other special code is necessary, I just add appDelegate.m method with a postNotification, somewhere some code will append a button
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType {
if ([userActivityType isEqualToString:#"INSendMessageIntent"]) {
[[NSNotificationCenter defaultCenter] postNotificationName:#"modeTest" object:nil];
}
return YES;
}
Now ask Siri "Send message with 'AppName' " a view from my IntentWiewController.m is display, you can abord process by touching screen, application is running now but Notification is send, some process can easily be done like adding any secret control. Next run will hide button.

Return to sourceApplication after openUrl request is completely handled

I'm implementing an iOS app that handles a custom protocol.
Writing the method application(openURL:sourceApplication:annotation:) in my AppDelegate was easy but I'm left with a problem: I want that - once the user have done with the request - my app move to the background and send the user back to the caller sourceApplication (e.g. a browser, a QRCode reader, or any another app).
This is just like the difference between "tel:" and "telprompt:" url calls: in the former case the phone app remains active, in the latter case, after the call, the user is send back to the sourceApplication.
In order to let my app handle my custom protocol like "telprompt:" does, the only way I can think about is terminate the app once the user action is completed... but this is against iOS Human Interface Guidelines (they say "Don’t Quit Programmatically") and my app can be rejected by Apple.
On Android it is easy: you respond to an Intent with an Activity and when you call finish() on that activity the user is back to his previous app/browser/whatever.
Anyone knows a good way to achieve this on iOS?
Just to clarify:
my app don't call openUrl, it responds to openUrl requests from browser, QRCode reader, other apps;
I don't have to make phone calls;
when I handle a request I ask the user for some data, contact a server, and that's it: the interaction is finished and it would be very nice to drive the user back to previous app without let him use the home button.
I believe you should call openUrl when you are done, with the source app url in param.
That's what facebook does when you use the "connect with facebook" API.

Generating Remote Control Events from my app

I have two questions regarding Remote Control Events on iOS:
I know that music applications are registered to remote control events and then can receive such events from the iPhone's player widget.
Let's say I want my app to fire such events, is that possible?
How does headphones for example generate those events?
Without private API, you cannot send remotecontrol event to your application.
The reason is we cannot create such an Event (UIEvent) to send out by using:
[[UIApplication sharedApplication] sendEvent:anEvent];
You can, however save a registered event then play back by calling the above-function.
I don't know if it possible for headphone events but with private API, you can send some events like: home button press, power button press or mouse events (not tested).
You should read this book:
http://www.amazon.com/gp/product/1118057651/ref=pd_lpo_sbs_dp_ss_1?pf_rd_p=1535523702&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=0321278542&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=0T2AMHJCEEKJN41YJHD5
It'll be a hard work to make this works.
Take a look at GSEvent to know how to send an event to OS (iOS).
Edit: I've found 2 event types in GSEvent.GSEventType:
kGSEventHeadsetButtonDown = 1018,
kGSEventHeadsetButtonUp = 1019,
PS: - this use private API so it will be rejected if you post this app to AppStore.

Send SMS without presenting MessageComposeViewController in iOS

I am working on sending SMS demo. I want to send how to send the SMS and how to set the delegate to MessageComposeViewController. and in order to send the message we have below line
[self presentViewController:messageController animated:NO completion:nil];
This line will present the MessageComposeView on screen with SEND button. And Once we click on send button it sends the message. What I want is to send the message directly without presenting this MessageController on screen. Please help how can I do this.
In this related question, Apple has restrictions in place on being able to send a SMS message without the user clicking the SEND button.
Apple really wants the user to be in control of the SMS functionality of their phone. Otherwise all sorts of data could be flying off some random app (e.g. spamming your contacts with "try this app out!", which would not be very friendly nor very nice).
One of the answers in this question does have a potential non-MFMessageComposeViewController solution, however I have a feeling that if Apple catches you doing this they might deny your app from being approved for the app store.
You could send the message using some webservice on the internet. http://client.suresms.com/ProjectInfo.aspx?Info=3 or www.clickatell.com. They have bunches of API for sending messages.
In SureSMS simply create an account and make a http request to
http://suresms.com/Script/GlobalSendSMS.aspx?login=[youraccountnumber]&password=[yourpassword]&to=[phonenumber]&Text=Hallo.
Remember to URL encode the message text and use countrycodes. Thats it.
You have to present MessageComposeViewController.It's not possible to send without presenting it.
MFMessageComposeViewController has delegate method while delete/send/save. which only perform while we present it.
(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
You can't do it without MFMessageComposeViewController. Apple won't allow to send SMS without user interaction.
As per document
You must not modify the view hierarchy presented by this view
controller. You can, however, customize the appearance of the
interface using the UIAppearance protocol.
I've alternate solution of this, Alternative way can be Using web service API. Create a web service at server side that send a message to specific number(s) that accept numbers as parameters with request.(according to your requirement)
As using Web server or external sms provider can do it.
It is NOT possible . Apple willn't accept your App. Apple will reject your App if you do like that. Human interface guidelines should be followed up.

How do I tell if app has been opened without URL?

I know I can check if a URL has been used to open my application, like so:
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
sourceApplication:(NSString*)sourceApplication
annotation:(id)annotation'
... but how do I check if the user has only returned to the app (and update my interface accordingly), without a URL being used? The use case is when logging in to Facebook or Twitter via Safari, and then user just goes back to the app instead.
Use applicationDidBecomeActive or applicationWillEnterForeground

Resources