iOS - Call ended notification - ios

don't know if it's possible, but I have an app that prompts for a number to call. Then the "phone app" is called and the call goes on as usual
After the call ends I would like to trigger an event that makes the user "rate" the call made, always inside this app. I don't need to store any info from the call just done, since the call was already triggered from my app, so I already have the number
Is there a way to trigger those kind of events in iOS?

You need to use CTCallCenter and add a callEventHandler to be notified about state changes to the call.

Related

Rewarded Interstitials - How to react to a user cancelling an Ad? (AdMob Google Ads, iOS)

I'm implementing GADRewardedInterstitialAd into a game.
https://developers.google.com/admob/ios/api/reference/Classes/GADRewardedInterstitialAd
I'm using presentFromRootViewController:userDidEarnRewardHandler to react to the user finishing the ad.
Now I'd also like to know how to react to the user cancelling the ad.
If I continue directly after calling presentFromRootViewController, the callback handler will not have been called yet, because the systems works asynchonous, as is to be expected. So any game animations (e.g. screen fade, dialog close) will have to be stalled.
If I rely only on the handler, I won't get a callback when the ad was cancelled.
My solution would be to build in a timer that waits 30+1s to give the handler a chance to get called (hopefully on the next main thread dispatch cycle), and then react to it not being called yet (assuming a cancellation by the user).
I really hate that plan.
It's not deterministic.
It doesn't use callbacks/delegates/handlers (which are great exactly for this kind of thing)
I have to write the timer code and keep a boolean flag somewhere... it's messy.
It adds an arbitrary delay to the user experience (30+1s) when they close the ad!!
Am I thinking the wrong way about this or is this just the way Google has made it and I'll have to live with it?
Edit: please note that I'm talking about the new GADRewardedInterstitialAd API, not GADRewardedAd.
I've figured it out; it works by setting GADFullScreenContentDelegate fullScreenContentDelegate and implementing adDidDismissFullScreenContent.
In there you can check if this particular instance of GADRewardedInterstitialAd did not get a reward yet (as notified by userDidEarnRewardHandler...)
This all hinges on the assertion that adDidDismissFullScreenContent gets called AFTER the userDidEarnRewardHandler, else I will already have assumed there was no reward. Let's hope that is always the case.
https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Protocols/GADFullScreenContentDelegate

Cordova: Hybrid iOS App Pause event doesn't get fired when making a phone call

Does the iOS app go to the background when we make the call using tel://123456789 ?
I have an iOS app that requires to log any outbound event happening through our app (like sending mail, calling, etc).
For Calling
we use some thing like :
in this case dialler opens up and makes the call but pause or resume events never gets
triggered . So basically we dont have hook/event after the call was ended to make the log
entry for call .
Though while replicating the same flow on android proper events(resume, pause) gets fired.
For Mail
we use some thing like :
in this case mail client of the user gets opened and our hybrid app goes to background and once mail is sent and the user returns to the app "resume" event gets fired
We need something similar for the phone call. Any pointers will be really appreciated.
You could try to listen to the click on the a tag then trigger that event yourself if it is not triggered by Cordova, that way you don't have to change your code. Using jQuery:
$('your_a_tag').on('touchstart', function(event){
$(document).trigger('pause');
});
Alternatively, you could open a support ticket on cordova-ios repo.

userNotificationCenter(_:didReceive:withCompletionHandler:) not be called when a notification action is selected

I am trying to get actionable notifications working and I have gotten the actions to display when the notification is expanded, but I cannot get the delegate function to be called when I select an action. I am declaring self.notificationCenter.delegate = self in application(_:didFinishLaunchingWithOptions:), and, if I'm understanding correctly, when an action is selected it should call userNotificationCenter(_:didReceive:withCompletionHandler:), passing in the UNNotificationResponse object. But that method never gets triggered in my code. Any ideas why that may be happening?
The method you have mentioned above gets called as soon as you receive notification.
The method which is executed after clicking on action on notification is,
application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
I figured out the issue. To handle notifications with content you have to add a service extension as a new target in the project. The last thing I ran was the service extension so the debugger wasn't stopping at breakpoints in the main app. I didn't know service extensions are essentially treated like completely separate apps. Since I was still in the process of working on the content of that method, what was in there was not working and it was hitting the breakpoints, so I thought it was not calling that function like it should.

TouchID calls applicationWillResignActive and applicationDidBecomeActive

I am wondering if this is intended by Apple that these lifecycle methods are called upon using TouchID functionality.
Is there any possibility to check if the touchID process is calling these methods (I want to avoid things like a BOOL in app delegate which is set if touchID input is currently shown or not..)
br
Im guessing the problem you're having is that you have code in applicationWillResignActive and applicationDidBecomeActive that affects the view controller that requests Touch ID-validation and that it sets off a tricky loop.
What you need to do is move those calls to applicationDidEnterBackground and applicationWillEnterForeground, because they're not invoked when the Touch ID-mechanism is called.
To explain the sequence, when your app starts the following sequence executes:
applicationDidBecomeActive
..other stuff your app does
Your app invokes Touch ID, which fires:
applicationWillResignActive
... Your app is disabled until the user verifies fingerprint (fails or
succeeds) ...
applicationDidBecomeActive
If you have code in applicationDidBecomeActive -or- applicationWillResignActive that affects Touch ID, you will create an endless loop or worse, you will create code that is riddled with flags and special cases.
Instead you should invoke Touch ID in two cases:
When your app starts (usually in didFinishLaunchingWithOptions)
When your app's applicationWillEnterForeground is called.
You can create a static bool in your login script that you can check from your AppDelegate!
static var isShowingTouchID = false
Then before your context.evaluatePolicy call, you can set it to true, and in the callback function, set it to false. I believe you use the reply argument to set a callback to this.
Then in your AppDelegate, check the status of this bool.
Originally I was using a public variable in AppDelegate and setting that, but I feel similarly in that I didn't want to do that. Frankly, I don't like this solution either, but it was the only one I could come up.
I even tried overriding viewDidDisappear in my login script, but I quickly found out that it was not being called even when I tapped "Cancel" on the touch ID prompt.
If anyone has a better solution, I would love to know.

After document.reload, messagePushed and urlLoaded events fired again

For both forge.event.messagePushed.addListener and forge.urlhandler.urlLoaded.addListener:
Whenever I fire a forge.document.reload() or document.location.reload() after the app was started using a push notification or urlhandler, either of those events will fire again.
I think trigger.io saves the notification/urlhandler data somewhere in the location in such a way that upon reload the app thinks that it was triggered again by either of those events.
Any way to clear that data?

Resources