Determine which button was tapped on system alert - ios

I am presenting SKStoreReviewController.requestReview() and I want to have a boolean in UserDefaults which I would make true in case the user taps on Cancel.
Is there a way to determine if cancel was tapped considering this is a OS alert?

There isn’t a way to access which button was selected. I’m curious why you would you need this functionality? The OS will decide if the user should be shown the alert depending on a few factors including when the user last left a review or canceled.
Apple Developer Site:
https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview
Although you should call this method when it makes sense in the user
experience flow of your app, the actual display of a rating/review
request view is governed by App Store policy. Because this method may
or may not present an alert, it's not appropriate to call it in
response to a button tap or other user action.

Related

How can i check what user did with SKStoreReviewController modal?

I have a few questions i could not find an answer to.
Can we find out if user tapped cancel/submit?
Can we know if user already give review? (To not show him modal again)
If user give a review and method to show review modal is called will it appear?
No
Apple handles that
No
You can read more about it here.
I include a link to a similar answer I posted that helps provide some insight into how the view is presented if you'd like to see the technical side.
SKStoreReviewController buttons hidden under keyboard
This answer goes into detail about the presentation of the view as well which may be of interest (how often it is shown, when it is not shown, etc)
Why the SKStoreReviewController does not let me submit a review?
Here's an idea. Not tested, but feel free if you have any other ones.
When you decide to run: SKStoreReviewController.requestReview() so the user is prompted with the native "Rate in the app store",
Set and control a timer.
Then in the appdelegate/applicationWillEnterForeground control this timer:
- If the user selected "submit", the app will probably go to background within the next 5 to 10 seconds. So if the app hit this method and the elapsed time is less than (i.e) 10 seconds, than (probably) means that the user went to the Apple Store.
- Meanwhile, if the timer hits 30 seconds, stop the timer and save your guess: The user didn't submit the review.
Also, many apps present a custom popup asking the user if they like the app and if so then they present the native SKStoreReviewController.requestReview()

SKStoreReviewController.requestReview() stop to work in debug mode

I have an app that I call the method SKStoreReviewController.requestReview () after 10 times that the user performs some action. The prompt stoped to appear even the debug show me that the method requesrReview is being called.
What's can be happening?
From the Apple docs:
Although you should call this method when it makes sense in the user
experience flow of your app, the actual display of a rating/review
request view is governed by App Store policy. Because this method may
or may not present an alert, it's not appropriate to call it in
response to a button tap or other user action.
The popup will only display sometimes, and it's dictated by the SKStoreReviewController as to when this will be, so you can't guarantee it will ever be displayed.

Which alert would be displayed if there're many competing alerts?

In iOS, many alerts can occur at a time in practice.
For example, if you're requesting a Photo Album (or whatever) permission, OS will present an alert. At a same time, programmer can UIViewcontroller.present() an UIAlertController instance as at their will.
What alert would be chosen at first place in this case?
I don't know the internal implementation, but according to my experiment on iOS 10.1.1 real device, alerts are shown in this order.
System alerts. Alerts that presented by operating system itself. (such as Photo Album permission request) This is the highest priority. If any of this alert gets presented, any other in-app alerts will be hidden temporarily, and shown again after end-user make a choice on the system alert. Priority between system alerts are unknown.
Your in-app alert. You can present only one in-app alert at a time because you are supposed to use UIViewController.present method to present an alert in current version of iOS. And this method will use your nearest presentation-context VC or root VC of its window. In either case, Apple is actually enforcing you to present only one alert at a time, and control presentation priority of the alerts yourself.

Delegates not available on BLE Authentication

I am able to read and write data from my iOS app(Central). Just after Delegate connectPeripheral:periphal is called, OS gives an alert asking for authentication PIN with two buttons "Cancel" and "Pair".
I am not able to get any notification when user presses "Cancel" or "Pair" button. I am also not able to detect if the pairing is successful or not.
self.peripheral.state always returns 2 (connected)
I have done some research to handling Cancel event of pairing popup but unfortunately apple doesn't provide any delegate to handle it.

Cancel button on UIActionSheet on iPad

The iOS Human Interface Guide says that on an iPad "Do not include a Cancel button when the action sheet is displayed without animation, because people can tap outside the popover to dismiss the action sheet without selecting one of the other alternatives". As a result, the Cancel button is not shown in these cases.
This is NOT intuitive. People are used to seeing a Cancel option whenever an action that can be cancelled is shown, and they may get confused if they don't see one. They may not realize that tapping outside the popver means Cancel.
The reasoning of "clicking outside the window to cancel" could have been used for PCs and Macs as well, but it isn't. A Cancel button is displayed in these systems.
I'm inclined to include an artificial Cancel button, but I'm afraid that this is against Apple HIG policy and my App will be rejected.
What do you think?
As someone who just encountered the same issue, I agree. It's not intuitive whatsoever!
As for Apple's recommendations
"Do not include a Cancel button when the action sheet is displayed without animation, because people can tap outside the popover to dismiss the action sheet without selecting one of the other alternatives." (p121)
"An animated action sheet should include a Cancel button, because people need to be able to dismiss the action sheet without closing the popover" (p121)
Will Apple reject your app if you don't follow these guidelines? This answer may offer some insight:
Will Apple reject my app if I do not do this?

Resources