How to get cancel and call user action from UIAlertView - ios

I am trying to get user action after displaying alert to call on number (UIButton) click.
Problem : When user clicks on number for multiple times it shows alerts for that many instances.
Expected Result : I want to show alert only once.
Following is the line to display alert on number (UIButton) click :
UIApplication.SharedApplication.OpenUrl(url)
I am thinking to disable button action after single click so user can see only one alert.
Can anyone please tell me how to get cancel and call button action when user interact with alert ?

UIApplication.SharedApplication.OpenUrl(url) will always show an alert to user for selecting whether he wants to make a call. So every time you call this api, an alert will show up.
If you want to check if the url fits your request you can use UIApplication.SharedApplication.CanOpenUrl(NSUrl url). This function probes whether there is a handler for the provided URL on the system. For example, if you call this function with "tel://4806814449" on an iPhone, this will return true, but will return false on an iPod Touch.
When this method returns true and the phone numbers are what you want, call the OpenUrl(url) to show the user authentication. Otherwise show the warning alert.
Moreover we should use UIAlertController instead of UIAlertView on iOS 8+.

Related

Determine which button was tapped on system alert

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.

How to programmatically customize "Authentication is disabled, try again in 1 minute" iOS

I want to programmatically customize the "Authentication is disabled, try again in 1 minute" alert, that appears when I put the wrong passcode 5 times.
I don’t want to remove the blocked state, I only want to put another button in this alert and disable the existing cancel button.
The objective is to make a better callback, because when this alert is shown, and the users taps cancel, the callback is “UserCancel” and this is the same callback you get if the user taps the "Cancel" button before being blocked.
I want to determine which reason resulted in the cancellation of the passcode request.
It is possible to do this? If so, how?

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.

XCUITest: Auto-Accepting System-Alerts. Need more fine grained control

I have read that addUIInterruptionMonitorWithDescription could be used to accept / tap on a particular button in a system alert. On recently trying some test code out, I was doing the following:
Adding a Photos Alert
Adding a Calendar Alert
Adding a Location Alert.
On the simulator, I was surprised to find that the Calendar and Location prompt automatically had their "Allow" buttons tapped. For the Photos prompt, the "Don't Allow" was hit. My question is - is there no need for addUIInterruptionMonitorWithDescription anymore? I tried using it for tapping on the dialogs but it didn't do anything. Even when I tried to hit another button on the alerts, I didn't see it working. How do I tap on the individual buttons on a system alert her?
If there is an alert on screen, and none of your interruption handlers handle it, XCTest will dismiss it for you if you are using Xcode <9.1.
To gain control of the alerts, you should create an interruption handler for each alert, returning true from the closure when (and only when) you have handled the alert that handler was intended for.
If the test tries all your alert handlers or receives a true return value from any of your handlers, and there is still an alert on screen, XCTest will handle the alert itself.

IOS How do I use a button send a message?

I set a button, it jump to make a phone call view while be clicked!Now I set another button send a message while be clicked. How to make it just stay in APP view rather than jump to the phone send message view.
Phone calls cannot be made from within an app. You can only redirect the user using a telephone number URL.
This isn't possible without delving into private frameworks.

Resources