Post not yet marked as solved
I have been having a problem in our application while handling the VoIP notifications.
sometimes the didReceiveIncomingPushWith delegate function is invoked when a VoIP Notif is sent but when the call is accepted nothing happened from the caller's side, like the callback to the caller to notify him that the call is accepted doesn't happe.
And sometimes the didReceiveIncomingPushWith is not even invoked when a VoIP notif is sent.
here is a potion of the code.
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
NSLog("pushRegistry didReceiveIncomingPushWith() type:(type)")
// Handle the push payload
if let pushHashtable = payload.dictionaryPayload["aps"] as? [AnyHashable: Any] {
if let pushMessage = pushHashtable["alert"] as? String {
NSLog("push message=\(pushMessage)")
}
}
if type == PKPushType.voIP {
// Process the received push: if it is a VoIP push, this must be an incoming call because we deactivated push for REGISTER refresh from Kamailio server
if SipService.instance?.currentCall != nil {
// A call is already going on, ignore this VoIP push
NSLog("pushRegistry - voip push, and we already have a currentCall: we already received the INVITE, or it is a voip push for another call -> let's ignore it")
completion()
return
}
// We want to send a REGISTER anyway to get the pending INVITE message.
// Then, the incoming call will be notified in the SIP stack onCallNew(_ call: Call!) callback
// Since iOS 13, it is mandatory to report an incoming call immediately after a Voip push
// instead of waiting for the SIP INVITE (in EngineDelegate.onCallNew())
// See details here: https://forums.developer.apple.com/message/376630#376630
NSLog("pushRegistry - >= iOS 13 -> showing callkit before SIP INVITE")
if let callerSipUri = payload.dictionaryPayload["caller-sip-uri"] as? String {
NSLog("push caller-sip-uri=\(String(describing: callerSipUri))")
SipUtils.findCallerName(fromSip: callerSipUri) { callerName in
let customCallerName = (callerName ?? "Inconnu") + (CallKitService.instance?.CALLKIT_DEBUG_MODE == true ? " [PUSH]" : "")
DispatchQueue.main.async {
CallKitService.instance?.reportNewIncomingCallToCallKit(callerName: customCallerName) {
completion()
}
}
}
} else {
// That should not happen: Kamailio server is supposed to add the caller SIP URI in the VoIP push
DispatchQueue.main.async {
CallKitService.instance?.reportNewIncomingCallToCallKit(callerName: nil) {
completion()
}
}
}
// No call is going on, so we want to take this call, so we want to send a REGISTER if needed
SipNetworkMonitoring.instance.start()
} else {
NSLog("pushRegistry - not a VoIP push")
completion()
}
}
here is the reportNewIncomingCallToCallKit function implementation
func reportNewIncomingCallToCallKit(callerName: String?, completion: @escaping () -> Void) {
NSLog("Callkit - reportNewIncomingCallToCallKit from %@", callerName ?? "Inconnu")
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .generic, value: callerName ?? "Inconnu")
update.hasVideo = true
// we may already have reported a new call to CallKit
// (since iOS13, we must do it in the didReceiveIncomingPushWith() callback)
// In this case, the CallKit UI is already showing with caller="Inconnu": we will update it with the caller name.
if let currentUuid = currentUuid {
NSLog("Callkit - already a CallKit call showing -> updating the existing call ...")
self.cxProvider?.reportCall(with: currentUuid, updated: update)
} else {
NSLog("Callkit - now CallKit call showing -> new call ...")
let newUuid = UUID()
self.currentUuid = newUuid
self.cxProvider?.reportNewIncomingCall(with: newUuid, update: update) { error in
completion()
}
}
// dont configure audioSession here, wait for the Callkit "didActivate audioSession" callback
}
just to clarify : findCallerName is a function to get the called name from a list from the Backend with an escaping closure, (I tried to overpass that function and just give a default name to the caller but still same problem) .
ANY HELP PLEASE?
Post not yet marked as solved
I have an iOS app, which uses Notification Service Extension (NSE) for its functioning. When I build the app, I get the following error:
error: Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier.
Embedded Binary Bundle Identifier: (null)
Parent App Bundle Identifier: com.example.sample
This error occurs when NSE doesn't have the app's bundle identifier prefixed to it (Reference post).
In my case, the bundle ID of the app is com.example.sample and the bundle ID of the extension, com.example.sample.NSESample (checked these values in Project -> Target -> Signing & capabilities -> bundle identifier label). I believe this is as expected. I don't understand this error now, which says the embedded bundle identifier is null. I cleaned and built the app again..... same error.
According to this stackoverflow post, you have to enable 'Copy only when installing'. When I tried, it worked. I don't know what this setting means and how this solves the issue. I'm unable to find any documentation reg this setting. Idk if this is even a valid solution, because the error says 'Embedded Binary Bundle Identifier' is null.
Why is the embedded bundle identifier null (despite the Xcode interface showing a valid bundle ID)? How can I solve this?
Post not yet marked as solved
Hi. I would like my App to be notified when the phone rings. No, not CallKit-CallKit is for VoIP and does not cover Cellular connections (as of 2/26/24) but, thanks. To continue..
I understand ages-ago there was a Telephony Kit or Framework but, has been discontinued. Has it been replaced with something else?
I would like something that seems very simple:a) when the phone rings my App is notified, b) when it stops ringing (combine all possibilities; sent to voicemail, user cancels, user answers) my App is notified.
Yes, I understand UserNotifications can make things run but, as I understand it this feature is for the App to schedule notifications, not receive them? If you know of something in UserNotifications that I can leverage I would appreciate your input.
Lacking other possibilities I find myself wondering about Siri integration. Siri is notified about system events and generates notifications based upon these events. Is there some way to place my App downstream from Siri and receive system notifications? Thanks everyone.
Post not yet marked as solved
Firebase JS SDK require Notification check so we are added. But its not working in iOS and iPad.
Version: 17.3.1
Working MacOS Safari 17.3.1
Post not yet marked as solved
In an iOS UNNotificationContentExtension with a media player, I have an AVPlayer which can either play a WAV or an MP4 remotely depending on the push payload userInfo dictionary.
I have implemented mediaPlayPauseButtonFrame, mediaPlayPauseButtonTintColor, and mediaPlayPauseButtonType, have overridden canBecomeFirstResponder to force true, and set the view to becomeFirstResponder when the AVPlayer is added.
I have implemented the UNNotificationContentExtension protocol's mediaPlay and mediaPause methods. I also have subscribed to the .AVPlayerItemDidPlayToEndTime (NS)Notification and I call a method on the VC when it returns, which calls mediaPause.
When the AVPlayer reaches the end, the .AVPlayerItemDidPlayToEndTime Notification is properly emitted, my method is called, and mediaPause is called. However, the media play/pause button provided by UNNotificationContentExtension remains visibly in the "playing" state instead of changing to the "pause" state. The button correctly changes its display state when the user presses the play/pause button manually, so it works.
And so, collective Obis Wan Kenobi, what am I doing wrong? I have tried resigning first responder, have no access to the button itself -- as far as I know -- and am wondering where to go next.
(This is the only thing not working by the way.)
Sanitized example:
import UIKit
import UserNotifications
import UserNotificationsUI
class NotificationViewController: UIViewController, UNNotificationContentExtension {
// Constants
private let viewModel = ...
private var mediaPlayer: AVPlayer?
private var mediaPlayerLayer: AVPlayerLayer?
private var mediaPlayerItem: AVPlayerItem? {
mediaPlayer?.currentItem
}
override var canBecomeFirstResponder: Bool {
true
}
// MARK: - UNNotificationContentExtension var overrides
var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType {
return .default
}
var mediaPlayPauseButtonFrame: CGRect {
return CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0)
}
var mediaPlayPauseButtonTintColor: UIColor {
return .blue
}
...
func didReceive(_ notification: UNNotification) {
...
// Process userInfo for url
}
...
@MainActor
func playAudio(from: URL) async {
let mediaPlayer = AVPlayer(url: url)
let mediaPlayerLayer = AVPlayerLayer(player: audioPlayer)
...
// view setup
mediaPlayerLayer.frame = ...
self.mediaPlayer = mediaPlayer
self.mediaPlayerLayer = mediaPlayerLayer
self.view.layer.addSublayer(mediaPlayerLayer)
becomeFirstResponder()
}
// MARK: - UNNotificationContentExtension
func mediaPlay() {
mediaPlayer?.play()
}
func mediaPause() {
mediaPlayer?.pause()
}
// MARK: - Utilities
private func subscribe(to item: AVPlayerItem) {
NotificationCenter.default.addObserver(self, selector: #selector(playedToEnd),
name: .AVPlayerItemDidPlayToEndTime, object: item)
}
@objc
func playedToEnd(notification: NSNotification) {
mediaPause()
}
}
Post not yet marked as solved
I am checking the Push Notification Console of Cloudkit to understand my apps push delivery metrics. There are nice metrics in there to see push sends and discards. But I couldn't see any metric to understand "How many of the users opened the notiifications I send". Is there any way me to understand this statistic?
Also can we export this metrics without logging in to CloudKit like an API request?
Post not yet marked as solved
For a period of time, we have frequently received reports of users receiving duplicate message notifications.
We can ensure that the message is only sent once and there is only one ApnsId, but when it reaches the device, there are multiple duplicate notifications (2-3)
I suspect this may be related to iOS 17, as there seems to be some overlap in time. Have others encountered similar problems? We sincerely hope to receive help from society. Thank you for your help~
Post not yet marked as solved
In an iOS project, I have implemented the following delegate method to handle Notifications when app is in foregorund:
func userNotificationCenter (_ pNotificationCenter : UNUserNotificationCenter, willPresent pNotification : UNNotification, withCompletionHandler pCompletionHandler : @escaping (UNNotificationPresentationOptions) -> Void) -> Void
{
// When app is in foreground, notification is directly sent to
// the app by invoking this delegate method.
}
When building, I'm getting the warning. But my implementation is correct according to documentation.
Why is this method not recognized as the implementation of the UNUserNotificationCenterDelegate protocol?
This is the warning in text format:
Showing All Issues
<file path & line number>: Instance method 'userNotificationCenter(_:willPresent:withCompletionHandler:)' nearly matches optional requirement 'userNotificationCenter(_:willPresent:withCompletionHandler:)' of protocol 'UNUserNotificationCenterDelegate'
This is the image of the warning:
Am I missing some flag in a compiler setting?
My env:
Xcode 15.2, Swift 5.0, Deployment target - iOS 14.0+.
Post not yet marked as solved
Hi! I have recently added the functionality of notifications in my app. I can send notifications and I see them in my phone well.
The problem is that even if I have no notifications, the badge shows I have 3 and I can not remove this notification when I read the notifications. What it is strange is that even if I send new notifications, the number 3 is still there...
Hi, I need a feature in the iOS app that requires updating the user screen via FCM.
In other words, I have to update it with no sound and screen display, but this doesn't work.
When I remove the notification field, the notification will not be displayed to the user, but the sound will be played.
If I remove the sound field, I can make no sound, but the user will be notified.
If I remove both, I'm not getting this from the iOS app.
How can I solve this??
Which option should I send Push from the server??
I'm also using Notification Service Extension.
Post not yet marked as solved
Prior to .p8 tokens, we were using .p12 cert for communication with APNS. We have since migrated to use .p8 token within our 3rd party push notification provider however, we still have the .p12 cert associated with our AppStore provisioning profile.
Do we still need to maintain the .p12 cert to ensure the validity of the AppStore provisioning profile?
Will revoking the .p12 cert result in inability for Apple to recognize that the app has push notifications enabled?
Post not yet marked as solved
Apple requires declaring the use of UserDefaults in both the App and third-party libraries in the PrivacyInfo.
However, I also utilize UserDefaults in the Notification Service Extension.
Should I treat the Extension as part of the App and only declare it within the App project? Or do I need to separately declare it for the Extension as well?
Post not yet marked as solved
This question is a follow-on and clarification from this earlier post.
I'd just like to confirm that after an App Transfer has been completed, whether there is any need for a new release to be cut? Judging from the prior post, my understanding is that a new release would not be necessary, and that all the existing versions of the app will continue to connect successfully with the APN servers.
The only necessary update would be the server connection between the APN servers and the server used to generate notifications, with a new token or certificate.
Is my understanding correct?
Post not yet marked as solved
We have noticed that the notification service extension stops working after app update for some users and it only starts working again after rebooting the device.
Does anybody else have similar problem and what was the solution?
Refer to the document:
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns#3394529
Error code 410, 'Unregistered' means: The device token is inactive for the specified topic.
But since February 1st, 2024, we did not got 'Unregistered' response any more. Do you know why ?
Post not yet marked as solved
I'm experiencing an issue while attempting to create a provisioning profile for push notifications. But I can clearly see that the push notification service is enabled for the new provisioning profile. However it still shows error.
Post not yet marked as solved
I have implemented Web push notifications for a website built on NextJs 13 using Firebase and they are working perfectly on desktop Chrome, Safari, and Android Chrome. But on IOS after adding the website to the home screen, the user initially starts receiving notifications after 3-4 notifications even if the user does nothing and just leaves the PWA open, the user stops receiving notifications foreground and background. On further debugging, I found out that the FCM device token gets changed.
I have no idea why it is changing automatically without doing anything It happens only for IOS.
IOS version 17.3 and 16.7, Firebase version 10.7.1
Is this a bug? or if someone can guide me on this?
How do you wake up an app without using push notification? I am developing a medical app which is isolated from the internet for cybersecurity/HIPAA reasons. When the iPhone is locked, I would like the app to launch, or return to the foreground, when the server notifies it that an event occurred. Is there a way implement this using Swift?
Even in the event of a disaster, push notifications are used to notify smartphone owners.
However, we have received requests from customers for an app that assumes that the LTE network is disconnected due to base station inconveniences during disasters, and communication from the Apple cloud cannot be considered. In that case, you would like to send push notifications to the iOS app on-premises within the customer's server, but there is a way to do that.
Post not yet marked as solved
Hi all,
More than a iOS dev i'm first of all a support tech.
My company develops and makes available to our customers three iOS apps like one who received 3,4k reviews on the AppStore.
Since many users of our apps upgrated to iOS 17 they started complaining their iPhones are not playing a sound anymore when a push notification is received.
Thought at first glance that it was a simple issue like the new "rebound" ringing playing less lounder than the usual "tri-tones". But i ran my tests and it's a fact: our applications doesn't ring anymore when push notifications are received (while other apps like Protonmail rings well on the same set-up).
Does any of you folks faced or are facing the same issue?
Is this a setting to do on each phone? Or can it be solved by improved development (I wish it could)?
Thank you very much for reading and feel free to ask any further infos.
Kind regards,
Pierre