UIBarButtonItem nextResponder call - ios

Looking on the web (https://github.com/Musixmatchdev/ObjectiveHeaders/blob/master/Headers/iPhoneOS6.0.sdk/UIKit/UIBarButtonItem.h) I found that UIBarButtonItem is implemented nextResponder selector.
However that's not part of the public API of UIBarButtonItem but it is in UIResponder class (which sadly UIBarButtonItem does not inherit from).
Am I authorized to use it or could it be refused by Apple ? (I would have asked on Apple Forums but it's gonna be down for a while I believe :)
Thanks a lot,
Jack Pardshe

Sadly, UIBarButtonItem is based on crippled UIBarItem, and neither of them implements nextResponder method. So, it's considered a private (non-public) API, and according to Apple App Store review guideline pt.2.5, "Apps that use non-public APIs will be rejected".
Note: Apple Developer portal is down now, but one can easily find the guide on the net
P.S. Please describe the reason of using nextResponder of UIBarButtonItem - I'm sure there are more than one way to achieve it.

Ok I found a solution for my specific issue:
I forward calls to [[UIApplication sharedApplication] sendAction:to:from:forEvent:]] selector which in turn (with the from parameter) uses UIBarButtonItem nextResponder. So this is an indirect reference to it using public API.
However I think that Apple is just using a respondsToSelector:#selector(nextResponder) on an id parameter in this method. So doing the same thing inside a custom code (write a method which take an id parameter and then call nextResponder on it) might also be a solution to use nextResponder selector whithout being seen as using the private API but this is just an hypothesis.

Related

Obj-c - Show 'Pay with Apple Pay' button?

I've setup Apple Pay in my app, and after reading the documentation, it says not to just use a .png for the 'Pay with Apple Pay' button, but rather to use their documentation code to show the button (as then, it is exactly to spec). I can't seem to find the code for the Pay With Apple Pay button (obj-c) anywhere?
As mentioned in the documentation
https://developer.apple.com/library/archive/ApplePay_Guide/CreateRequest.html#//apple_ref/doc/uid/TP40014764-CH3-SW2
To create an Apple Pay–branded button for initiating payment request
on iOS 8.3 or later, use the PKPaymentButton class
ref:
https://developer.apple.com/documentation/passkit/pkpaymentbutton
e.g.
PKPaymentButton *button = [PKPaymentButton buttonWithType: PKPaymentButtonTypePlain style:PKPaymentButtonStyleBlack];

Get referrer string for Universal Link?

I implemented Universal Links in our iOS 9 app and they work by calling a method in AppDelegate.swift, in which I get an NSUserActvity with an URL attached to it.
Is there a way to get the (HTTP-) referer? I need to know on which website the user has tapped the link that opened the app.
You should be able to use NSUserActivity > referrerURL instance property. See https://developer.apple.com/documentation/foundation/nsuseractivity/2875762-referrerurl.
No, there is no way to get the referrer.
An Apple employee made that pretty clear on the developer forums: https://forums.developer.apple.com/thread/65423
They say that the only way to get some kind of referrer would be to append it to the URL. Maybe take a look Google's campaign tracking URLs (utm_...).
I found another interesting solution if you need to support iOS 9 and 10 - https://appmetrica.yandex.com/blog/referrer-based-tracking-dlya-ios-tochnaya-atributsiya-dlya-lyubogo-istochnika-trafika.
Since iOS 11 I guess can be used NSUserActivity > referrerURL.
In short:
SFSafariViewController uses the same cookies as Safari app.
You can open invisible SFSafariViewController inside your app.
If your site contains some cookie - use Universal Link to pass it back to the app.
Though it requires to implement something like tracking link on your site.

Is UIPageControl customization legal?

I've found out that it's very easy to customize UIPageControl page images (I've checked it for iOS7/8):
[self setValue:[UIImage imageNamed:#"my_icon_for_off_state"] forKey:#"_pageImage"];
[self setValue:[UIImage imageNamed:#"my_icon_for_on_state"] forKey:#"_currentPageImage"];
But I wonder can I publish my app with this code, because these variables are declared as private in UIPageControl?
As per Apple, you can't use private API's in your project.
However we can. Don't worry. Just be honest and while submitting the app, inform them that you have used xyz code.
Apple DON'T approve the app where insecure private API's are used.
Many times, I used private API's and Apple approved it.
Honesty is simplicity.
One of the example
As you've already stated, those properties are declared private by Apple so you will be unable to use them. You can change the tint color of the page "dots" by using pageIndicatorTintColor and currentPageIndicatorTintColor.

How are iOS7 Keyboard Shortcuts Implemented?

I saw this MacStories article about some apps adding keyboard shortcuts to iOS7 apps. How is this implemented? Is it a private API that I shouldn't be using?
I've done some searching around the iOS developer library on http://developer.apple.com, but I couldn't find anything.
There's already a SO question for this. See this answer and this blog post for details.
Basically, there is a new keyCommands property on the UIResponder class in iOS7. Override the getter to return an array of UIKeyCommands.
Hat tip to Сергей Малетин for the comment.

Would apple allow this this non-public method?

I am using some non-public method to better control the slide effects of my application, for example:
[self dismissModalViewControllerWithTransition:2];
After trying to upload my App with the Application Loader I got the message that I can not use such non-public methods. I found in stackoverflow a nice workaround here: How does Apple know you are using private API?
So, I've adapted my code:
int tvalue = 2;
objc_msgSend(self, sel_getUid("dismissModalViewControllerWithTransition:"), tvalue);
After changing the code, the Application Loader did accept my binary. So here my question: can I get any problems when the App gets revised by apple?
Thanks in advance.
You cannot. Your app was not rejected because Apple could not track properly your code. Skip using non-public methods.

Resources