I want to trigger a remote control event such as UIEventSubtypeRemoteControlTogglePlayPause programatically. The application that I have in mind is a voice remote control application (even if it already exists) which receives the command "Play" and it simply generates the event UIEventSubtypeRemoteControlTogglePlayPause. Any app registered as the first responder for this event will get it. I.e. my app simply translates voice to remote control commands.
Ideas?
It's not possible to generate UIEvents programmatically.
You can do it by using private API (google synthesize UIEvent). Some testing frameworks do that. Also, for testing, you can inject Apple's UI Automation framework into the application and use its method to generate events (mostly touch events, headers available on github).
However, synthesizing events is something you can't do in an Appstore application. If you need to do that, it's a bad design.
Related
I am new to iOS development and looking for some help. I am wondering if an iOS app can send interrupt to itself?
In particular i want to send a mediaServicesWereResetNotification to app to force a hard reset. Please suggest if it is possible. As per documentation this notification can be triggered by force fully restart media server on device. I want to check if I can just get the notification on my app without restart.
There's no need for a 'hard reset'.
As the documentation says, the iOS Settings app has an option to manually trigger this event (as many times you like):
You can trigger a media server reset by choosing the “Reset Media Services” selection under the Developer menu in the iOS Settings app. Using this utility helps to ensure that your app responds appropriately if media services were reset.
I am building xamarin.forms app. I need to run background service that runs irrespective of application state. The background service should run even after application closes. I can use dependency service, for android but how could anybody share there code?
Have a look at this plugin.
You can use local notifications, so there is no external trigger needed. You can show notifications with a local date/time trigger. Besides just showing a notification right away, you can also schedule them, or schedule more at a time. If you do, whether or not the app is running at that time a notification will popup and it would look like just like any (external) notification.
Install the NuGet package on both your shared, as well as your platform projects. It seems the examples on GitHub are outdated. Add this using to the classes where you want to use it: using Plugin.LocalNotifications;
Then you can access the functionality through:
CrossLocalNotifications.Current.Show("Good morning", "Time to get up!", 1, DateTime.Now.AddDays(1));
This will plan a notification for tomorrow. You can also cancel it, in the above example you give it the id of 1. You can then cancel it with:
CrossLocalNotifications.Current.Cancel(1);
This way you can plan a whole series, you just have to keep track of the ids yourself.
Another alternative plugin in this one which does the same in the end but has some different features.
I'm looking for the class that handles call duration UIView ( Or caller name ) for iOS 8
, So i could hook into it and find its frame position
What i tried and found so far :
I looked up the TelephonyUI private framework headers classes and Found nothing after so many hours of digging and trying
Sounds to me that it's related to MobilePhone.app but couldn't also find anything
syslog mostly logs data from it under Core Telephony Framework
On iOS 8 the in call UI no longers runs in MobilePhone or SpringBoard. It actually runs in a separate process - InCallService.app. It's works just like MFMessageComposeViewController I researched here. MobilePhone or SpringBoard (don't know for sure and it doesn't really matter), displays, what is called, remote view controller for in call view - it's a view controller which is being displayed in your app but the actual logic behind it runs in a separate process.
For example, when you display MFMessageComposeViewController to send SMS message from your app you actualy using proxy object which connects through XPC to another process where actual view controller code runs. Your app only sends user input to the process and displays results that it returns to you - remote view controller forwards method calls through XPC connection. You don't actually have any control over the controller - you can manipulate it through a very limited API provided by XPC service that implements the logic.
Obvious purpose of these remote view controllers is security. On iOS 5 there wasn't any and MFMessageComposeViewController was implemented just like a regular view controller. It meant that you could reverse engineer it to send SMS messages without user permission. And that exactly what some people did - there was AppStore apps that could send SMS messages silently using this code. Starting at iOS 6 that code requires special entitlement that AppStore can't have. MessagesViewService.app has it and through remote view controller running in it you can send SMS messages from AppStore apps but now you can't do it without the UI and user interaction.
Same with in call UI. You can test it by doing a call and then killing InCallService.app process - in call view will disappear. So in order to change something you need to hook InCallService.app. Unfortunatelly I didn't research it to tell you exactly which methods you need to hook but at this point it will be very easy. I suggest you start looking at PHInCallRootViewController, PHInCallRootViewControllerActual and PHCallParticipantsView. The latter has a very interesting method setSingleDurationTimerLabel:(id) which modifies _singleDurationTimerLabel ivar. It looks like duration label view.
This might be obvious but is it possible to have an iPhone app that replaces the default call manager. I would like it to listen register with the low-level services to receive and make calls. I am not sure if apple exposes this libraries to apps. At minimum I would like the app to be able to receive.
No, this is not possible. Apple doesn't allow this. You might be able to accomplish this through a jailbroken device but there would be no documentation to assist you and you would need to discover private APIs.
As noted on this answer
If your application is active when a call event takes place, the
system dispatches the event to your handler immediately. However, call
events can also take place while your application is suspended. While
it is suspended, your application does not receive call events.
I'm trying to look for a way as to how I can notify a user of new updates based off of a .Net API that I created. Much like that notification you get on facebook, I just need to alert the user that something has been updated. So I'm thinking I need a function that runs in the background while my user uses the app combined with a NSTimer.
Based on my research (and on this question https://stackoverflow.com/a/14835300/639713) apparently you can only achieve such a thing for VOIP and location services. And that using push notification is the only way. Is it really the only option that I can use for such a need? Or are there any other ways?
Thank you for your time.
You have two options:
While your app is open, poll the server every so often to see if there are any updates to report.
This will work only as long as the user has your app open, and as you note, your app will only be allowed to stay open for a long time if it happens to be a VOIP or navigation app.
Use push notifications to push updates to the user’s device.
The disadvantage here is that you will need to write some server-side code to talk to Apple’s push notification servers (as described in this tutorial). This may or may not be a big deal in your particular situation, but it’s the only way to get data to the user when your app isn’t open.