Generating Remote Control Events from my app - ios

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.

Related

Cordova: Hybrid iOS App Pause event doesn't get fired when making a phone call

Does the iOS app go to the background when we make the call using tel://123456789 ?
I have an iOS app that requires to log any outbound event happening through our app (like sending mail, calling, etc).
For Calling
we use some thing like :
in this case dialler opens up and makes the call but pause or resume events never gets
triggered . So basically we dont have hook/event after the call was ended to make the log
entry for call .
Though while replicating the same flow on android proper events(resume, pause) gets fired.
For Mail
we use some thing like :
in this case mail client of the user gets opened and our hybrid app goes to background and once mail is sent and the user returns to the app "resume" event gets fired
We need something similar for the phone call. Any pointers will be really appreciated.
You could try to listen to the click on the a tag then trigger that event yourself if it is not triggered by Cordova, that way you don't have to change your code. Using jQuery:
$('your_a_tag').on('touchstart', function(event){
$(document).trigger('pause');
});
Alternatively, you could open a support ticket on cordova-ios repo.

Send Events to Webview

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.

CocoaLibSpotify - receiving remote control events and setting now playing info

There's not much to my question I guess. I'm just curious about how CocoaLibSpotify works with AVFoundation and if it's compatible with how Apple needs me to register for remote control events and to set the now playing info in MKNowPlayingInfoCenter.
Apple says to receive remote control events my app needs to "Begin playing audio. Your app must be the “Now Playing” app. Restated, even if your app is the first responder and you have turned on event delivery, your app does not receive remote control events until it begins playing audio.'" however, that's all the documentation I can find... Does playing a track with SPPlaybackManager meet this requirement? What is the requirement anyway?
Thanks for your help again.
Remote control events work fine with CocoaLibSpotify without any modifications to the library at all, but only on the device and not in the Simulator (including iOS7's Control Center).
Taking the Simple Player example, I made the following changes:
Changed Simple_PlayerAppDelegate to be a subclass of UIResponder.
Overrode canBecomeFirstResponder: to return YES.
Implemented remoteControlReceivedWithEvent:.
In the callback to the playTrack: call to CocoaLibSpotify, added:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
These changes allowed Simple Player to receive remote control events when running on a device.

After document.reload, messagePushed and urlLoaded events fired again

For both forge.event.messagePushed.addListener and forge.urlhandler.urlLoaded.addListener:
Whenever I fire a forge.document.reload() or document.location.reload() after the app was started using a push notification or urlhandler, either of those events will fire again.
I think trigger.io saves the notification/urlhandler data somewhere in the location in such a way that upon reload the app thinks that it was triggered again by either of those events.
Any way to clear that data?

How to detect with PhoneGap on iOS if call is made or not

When using the telprompt intent on iOS like
window.location = 'telprompt://' + phoneNumber
the user gets prompted to either call the number or cancel.
Is there a way to know which of the two actions the user has made?
Looking at the PhoneGap docs the "startcallbutton" event is only supported on BlackBerry.
All you can do is listen for the pause event.
document.addEventListener("pause", yourCallbackFunction, false);
This event will be fired when there is an incoming call or starting a call.
or you could look into the phone listener plugin and try to write it for iOS
https://github.com/devgeeks/PhoneListener

Resources