Objective-C: Change iOS headphones buttons actions - ios

I need to bind own actions on iOS headphones buttons.
For play/pause action i found solution:
Add audio background in .xcodeproj
Implement method remoteControlReceivedWithEvent
Set self as firstResponder
I can't set my class as first responder, bcs my class is subclass of UIViewController. For this method class must be a subclass of UIResponder. So i put this method in AppDelegate and create notifications.
1. Is there other way to put remoteControlReceivedWithEvent in my class, without changing superclass or using notifications?
2. Can i change volume up/down actions?

To be honest I think this is a bit of a grey area. Personally I think that if you alter the functions of those buttons your app will get rejected from the Apple iOS App Store Review process for breaching guideline 10.5. However I also don't believe that Apple will test your App with headphones unless you specifically state that headphones are required for your app to work. Though if your app needs headphones to access certain functionality and you didn't tell Apple so they didn't test it and they found out this could possibly get your account banned for dishonesty.
So in all honesty based on the review guidelines I'd say this can't be possible for the reason already stated and I also think that you'd need to access some private APIs to actually achieve this. So would also be rejected under 2.5.
2.5 Apps that use non-public APIs will be rejected
10.5 Apps that alter the functions of standard switches, such as the Volume Up/Down and Ring/Silent switches, will be rejected
So if you are going to continue with this I'd tread very carefully about what you (1) do to implement it and (2) what you tell Apple when it goes into the review process. If it was me I'd tell Apple that there is functionality behind those buttons.
However I really don't think this would get past the review process for 2.5 no mind reaching 10.5

Related

Apple keeps rejecting app with AdMob because of bluetooth notification string not correct

Since IOS 13 came to live old 3 party APIs stopped working, In my app i needed to fix few because of that so i needed to fit it to IOS 13.
Since then Apple keeps rejecting my app because of Bluetooth user notification is not correct.
I just don't know what to write there, It is so annoying. I have to add it because of AdMobs and there is nowhere to say what to write over there.
I don't user BT in my app, it is just the AdMobs beacons that needs it probably.
I've tried:
and
And i will probably will have the same issue with the calendar message also.
When i try to remove it they demand it and then not approving it.... I understand maybe the first one but what wrong with the the second one? why is that no clear enough for them?
10x
see apple docs below: https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/requesting-permission/
Explain why your app needs the information. Provide custom text (known
as a purpose string or usage description string) for display in the
system's permission request alert, and include an example. Keep the
text short and specific, use sentence case, and be polite so people
don't feel pressured. There’s no need to include your app name—the
system already identifies your app. For developer guidance, see
Protecting the User's Privacy.
you're not explaining exactly why you need access to bluetooth. you must be specific. saying, "XYZ app needs access to bluetooth to interact with beacons to serve you location based advertisements"
something like that should do. no cutting corners, no trying to put it off on Google, just say it like it is and you'll likely pass through app approval without a problem.

Listen for iOS device power button presses

I am creating an app, which needs to do something when the user presses the power button 5 times.
I figured out that it's difficult to implement in iOS, but I think it's not impossible. How do I listen for power key events, even when the app is running in the background?
Can anyone help me to find solution?
you can tap a power key once and also you cannot detect the event from your application, this is not possible in iOS as far now, better try a different way to send alert with in your app, set some conditions with in your app and then send a alert based on those conditions if satisfied, I think this would be better,
Somehow ,If you try to override the existing functionality of the power key, apple will reject your app I think so,
You can't directly get the power button events. But there are notifications which you can count like UIApplicationProtectedDataWillBecomeUnavailable or UIApplicationWillResignActiveNotification. Or just register for all low level notifications with CFNotificationCenter and see if you find something fitting like com.apple.springboard.lockstate.
I don't think you can override system level actions like holding the power button, pressing the home button, overriding the mute sound switch within your own app. iOS system doesn't exactly behave like an normal computer OS, it's to much more limited.
Apple is not allowing you to use hardware components completely. They have added some restrictions. They provided the method in the app delegate i.e. applicationDidEnterBackground can catch the home button press .Also they has provided the the API's to access the camera,bluetooth etc .At least this much of API's I know which provided by apple publicly to access the hardware. You cannot access the other hardware elements in your application which not provided publicly by apple .If you are able to do this by any way then also your application will not approved by apple .

Is it possible, perhaps with Apple's permission, to switch an app to the foreground without user input?

We would like to be able to remotely control an app on an iOS device so that the app can be automatically brought to the foreground WITHOUT the user having to do anything, for example when the app receives a remote push notification. My understanding is that normally there is no way to bring an app to the foreground in iOS unless the user presses a button, because Apple has decided that it knows best, and that it is better for app developers and users not to have this possibility, because it could be abused.
We are working on a security-related app where we believe that there would be strong justification for this type of functionality (in a case where the user is not able to take any actions).
Two questions:
Is there any way to do this in iOS coding that others on similar posts have overlooked?
Does anyone have experience with whether Apple ever grants exceptions to this kind of rule if there is a good justification?
The answer is simple: NO, and there is no chance that Apple will agree to allow you to implement such functionality. The only app that does this is the Phone.app because that is its purpose.

UIEventSubtype missing elements

The enum UIEventSubtype (iOS UIKit Framework) contains events such as play, pause, next, seek, etc. However, the iPod Access protocol contains numerous other events, such as select, up, down and back (think iPod with clickwheel). The iPod app on iOS can receive these other events and respond accordingly (move selection up/down/back in playlists), but developer apps don't have seem access to these controls.
Does anyone know a way to receive these additional events in an iOS app (for jailbreak), other than opening the /dev/tty.iap port myself (or filing a bug report with Apple and waiting)? Perhaps there's a private framework that has what I'm looking for? I looked in the IAP framework but didn't see anything interesting.
#Victor Ronin had the right idea, in the Private Framework iPodUI I found a class IUAccessoryEventHandler containing methods like
- (void)handleDownArrowEvent;
- (void)handleUpArrowEvent
- (void)handleSelectEvent
When I hooked into them with a Theos tweak and inserted logging details, I was able to see that these methods were the ones being called when an external device was sending the commands.
Update: Unfortunately, the iPodUI framework were only available in iOS 5 and 6, according to the iPhone Wiki. Not sure if or where these methods are still available.
I don't have a ready answer for you, but since you are doing this on jailbroken device, you can use mobile substrate to inject code into iPod app and you can override UIApplication sendEvent to see all events, which it receives (including select, up, down etc).

Counting missing calls on iPhone/iOS

I'm quite new at iOS app development.
I'm starting to work on an app that should in somehow be able to count the missing calls that the iPhone has registered since the app is running.
I've read that in no way Apple is going to let me intercept incoming calls, answer them, reject them, or "whatever" them, but I wonder if we are allowed to count them.
I've found some people that say it can be done (well, I knew it is possible, cause LockInfo does, for instance), but I don't know if it's attached to jailbroken iPhones only.
Anyway, as far as I have seen, it must be done with some methods related to kCTCallStatusChangeNotification from CoreTelephony.h if I'm right (as seen in http://blogs.oreilly.com/digitalmedia/2008/02/when-it-comes-to-the.html), but I coudln't find much more info about it.
Hello and welcome to iPhone Development! :) As you have already pointed out, you can be informed through a notification if a call is happening. Great! But here comes the dark side of iPhone Development:
That's the end of the road. 95% of the "Phone Functionality" of the iPhone is private API and you don't technically have access to it.
Of course, you could header-dump the private frameworks and use them anyway, but that will get your app instantly rejected from the AppStore, which wouldn't be fun for anyone.
LockInfo is an extension for jailbroken devices - those guys are known for not caring too much about Apple nor Private APIs ;) Also, as you may have seen, LockInfo isn't on the AppStore because it would've never made it that far.
So Apple, why is there CoreTelephony?
Well, it's there for some very specific reasons. I personally use it to obtain the carrier name of the device for certain country specific restrictions in my application. The notification you talked about, along with others, tend to be used by developers to prepare your app for going into an inactive state (when the call comes in, your app is put in the background), so its used to pause tasks etc... CoreTelephony has never been intended for any deep level access to the telephone system of the iPhone.
So sorry, you can't obtain the information you're looking for using public APIs.

Resources