I am developing an app where the primary feature is to notify users.
To deliver notifications more effectively, I am considering using PushKit and CallKit.
Would it be acceptable under the guidelines to use PushKit and CallKit as an optional feature for an AI agent to notify users via a phone call?
Notifications
RSS for tagLearn about the technical aspects of notification delivery on device, including notification types, priorities, and notification center management.
Post
Replies
Boosts
Views
Activity
I'm working with a deeplink I have to implement to my app. The deeplink is working because in some cases i will explain later the method is being executed. So when I tap the deeplink with a deeplink-tester-web I detect if the url is which I want and, if it's the case, i post a notification to NotificationCenter with a string parameter I need.
Case 1. I tap the deeplink when the view controller with the addObserver method is at the background with the app itself. It works (the only case)
Case 2. The app is closed so the deeplink opens the app directly in that view controller (the method is no being called event if the notification is there) Why?
Case 3. The app is at the background but in another screen. When I tap the deeplink and, after returning to the app, travel to my viewController the method is not called when the ViewController becomes visible. Why?
I've not seen anything in the documentation that can help me and i cannot access to the array of observers because the API does not allow that
Thanks. Any help will be appreciate.
Code:
When the deeplink is tapped the app delegate method that manages universal links call to this code when the url is a specific one
@objc func handleRecommendedOffer(offerId: String) {
NotificationCenter.default.post(name: .deeplinkRecommendedOfferNotification, object: nil, userInfo: ["offerId": offerId])
}
In my viewcontroller viewDidLoad (i've tried also viewWillAppear too):
NotificationCenter.default.addObserver(self, selector: #selector(goToDetail(notification:)), name: .deeplinkRecommendedOfferNotification, object: nil)
@objc private func goToDetail(notification: Notification) {
if let userInfo = notification.userInfo, let offerId = userInfo["offerId"] as? String {
showLoading()
getOfferViewModel.getOfferDetail(id: offerId)
}
}
hi i'm testing the new certificate. I'm using the p12 certificate and without doing anything, the sandbox can still be functioned.
I assume the new certificate has already been installed in the default path by linux. so I execute
openssl s_client -connect 17.188.143.34:443 -servername api.sandbox.push.apple.com -verifyCAfile /etc/pki/tls/certs/ca-bundle.crt -showcerts
and i received
CONNECTED(00000003)
depth=2 C = GB, ST = Greater Manchester, L = Salford, O = Comodo CA Limited, CN = AAA Certificate Services
verify return:1
depth=1 CN = Apple Public Server RSA CA 12 - G1, O = Apple Inc., ST = California, C = US
verify return:1
depth=0 C = US, ST = California, O = Apple Inc., CN = api.development.push.apple.com
verify return:1
---
Certificate chain
0 s:/C=US/ST=California/O=Apple Inc./CN=api.development.push.apple.com
i:/CN=Apple Public Server RSA CA 12 - G1/O=Apple Inc./ST=California/C=US
-----BEGIN CERTIFICATE-----
...
so the server indeed has the certificate, is this correct?
Hi,
I'm working on an IOS app using capacitor. I'm trying to receive push notifications on my downloaded app from testflight. I tried with FCM and it's working on my android app but not on ios and the logs show no error.
This is how I retreive the FCM token:
const fcmToken = await FCM.getToken()
sendSubscriptionToBackEnd({
fcm_token: fcmToken.token,
device: platform
})
Then I have a job on my backend to send the push notifications:
def perform
fcm = FCM.new(
StringIO.new(Rails.application.credentials.google_application_credentials),
Rails.application.credentials.firebase_project_id
)
NotificationSubscription.find_each(batch_size: 100) do |subscription|
begin
response = fcm.send_v1({
token: subscription.fcm_token,
notification: {
title: 'Un nouveau signal a été publié',
body: 'Un nouveau signal a été publié, cliquez ici pour le voir'
},
android: {
priority: 'high'
},
apns: {
payload: {
aps: {
# alert: {
# title: 'Un nouveau signal a été publié',
# body: 'Un nouveau signal a été publié, cliquez ici pour le voir'
# },
sound: 'default'
}
},
headers: {
"apns-priority": "10",
"apns-push-type": "alert"
}
}
})
if response[:status_code] == 200
Rails.logger.info "Notification sent successfully to #{subscription.id} on device #{subscription.device}"
else
Rails.logger.error "Failed to send notification to #{subscription.id} body: #{response[:body]}"
# subscription.destroy
end
rescue StandardError => e
Rails.logger.error "Error while sending notification to #{subscription.device}: #{e.message}"
subscription.destroy
end
end
end
and the logs show that it's successful but i dont receive the notification. When I test from firebase console I receive the push notification on both ios and android capacitor apps. I also added this in the apple delegate:
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().token(completion: { (token, error) in
if let error = error {
NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
} else if let token = token {
NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: token)
}
})
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
}
I also tried using apns tokens and ther apnotic gem:
console.log('APNs Token:', token.value)
if (platform === 'ios') {
sendSubscriptionToBackEnd({
apns_token: token.value,
device: platform
}).then(() => {
displaySnackbar(`APNs token: ${token.value}`, 'success')
})
}
})
# Create the APNs connection outside the loop
connection = Apnotic::Connection.new(
auth_method: :token,
cert_path: StringIO.new(Rails.application.credentials.apns_key_path),
key_id: Rails.application.credentials.apn_key_id,
team_id: Rails.application.credentials.apple_team_id
)
NotificationSubscription.find_each(batch_size: 100) do |subscription|
if subscription.device == 'ios'
begin
# Create the notification for the current device token
notification = Apnotic::Notification.new(subscription.apns_token)
notification.alert = "Un nouveau signal a été publié"
notification.topic = Rails.application.credentials.apple_bundle_id
# Prepare and send the push
push = connection.prepare_push(notification)
push.on(:response) do |response|
if response.ok?
Rails.logger.info "Notification sent successfully to #{subscription.id} on device #{subscription.device}"
else
Rails.logger.error "Failed to send notification to #{subscription.id} body: #{response.status} - #{response.body}"
end
end
connection.push_async(push)
rescue StandardError => e
Rails.logger.error "Error while sending notification to #{subscription.device}: #{e.message}"
subscription.destroy
end
end
end
connection.join(timeout: 5)
connection.close
end
but i have a bad token error:
Failed to send notification to 223 body: 400 - {"reason"=>"BadDeviceToken"}
I, [2025-01-23T02:23:59.013407 #104] INFO -- : [ActiveJob] [ApnsNotificationJob]
I checked my aps entitlement env and its production, have all the certificates, keys.. so I dont understand why i can receive push notifications from firebase console but not from my app
I'm having an issue on my standalone watchOS app where the settings to adjust notifications does not appear anywhere on the iPhone or the Watch. I have successfully requested notifications access from the user and have successfully displayed a local notification to them. However, if the user ever decides to revoke my notification access (or if they deny originally and want to change), the settings pane for notifications does not appear anywhere.
I've looked in the following places:
On the watch in Settings > Notifications, however it looks like you can no longer edit per app notification settings directly on the watch (none of the installed apps on my watch appear in here). The only options are settings like "tap to show full notification" and "announce notifications" which affect all notifications (Why not? Especially for apps that don't have a iPhone companion app?).
On the iPhone in the Watch app (the app you set up your watch in), in Watch > Notification. My app does not appear anywhere in there.
On the iPhone in the iPhone Settings app, in Settings > Notifications. My app does not appear anywhere in there.
On the iPhone in the iPhone Settings app, in Settings > Apps. My app does not appear anywhere in there
I've tried:
Adding capabilities in Signing & Capabilities for Push Notification, Time-Sensitive Notifications and Communication Notifications
Building the app for release instead of debug
My app also requires location access and has successfully appeared in the settings pane directly on the watch in Settings > Privacy & Security > Location Services, however notification settings do not appear anywhere.
I have created a stripped down test app to try and that also does not work. This test code successfully asks the user for permission and (from a button in ContentView), successfully schedules a notification and displays it to the user when they're not in the app. Here's the code for my NotificationManager:
import UserNotifications
class NotificationManager: NSObject, ObservableObject, UNUserNotificationCenterDelegate {
static let shared = NotificationManager()
@Published var hasAuthorisation = false
private override init() {
super.init()
UNUserNotificationCenter.current().delegate = self
requestAuthorisation()
}
func requestAuthorisation() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { authorised, error in
DispatchQueue.main.async {
if let error = error {
print("Error requesting notifications: \(error.localizedDescription)")
}
self.hasAuthorisation = authorised
}
}
}
func scheduleNotification(title: String, body: String, timeInterval: TimeInterval) {
let content = UNMutableNotificationContent()
content.title = title
content.body = body
content.sound = .default
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: timeInterval, repeats: false)
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request) { error in
if let error = error {
print("Error scheduling notification: \(error.localizedDescription)")
} else {
print("Notification scheduled successfully.")
}
}
}
}
This issue has persisted across two iPhones (recently upgraded) and the watch was wiped when connecting to the new iPhone.
Am I missing some code? Am I missing some flag I need to set in my project somewhere? Please can someone with an Apple Watch try this code in a standalone watchOS app and see if the notifications pane appears anywhere for them? I've contacted Apple DTS, but they're taking a while to respond.
I am developing an application that uses NetworkExtension (Local PUSH function) And VoIP(APNs) PUSH.
Nowadays, I found a problem on this app doesn't handle incoming call of Local PUSH when receiving a Local PUSH after receiving an APNs PUSH.
My confimation result of my app and server log is below.
11:00 AM:
my server(PBX) requests a VoIP(APNs) PUSH notification to the APNs.
But my app does not receive the VoIP(APNs) PUSH.
At this time, my app is running on LAN (Wi-Fi without internet connection), as a result, NetworkExtension was running. so I think this is normal behaviour.
14:55:11 PM:
There is an incoming call from the my server(PBX) via local net, and NetworkExtension calls iOS API(API name is reportIncomingCall).
However, iOS does not call the delegate didReceiveIncomingCallWithUserInfo for the reportIncomingCall.
14:55:11 PM:
At almost the same time, iOS calls the delegate cdidReceiveIncomingPushWithPayload of VoIP PUSH.
(instead of call the delegate didReceiveIncomingCallWithUserInfo for the reportIncomingCall?)
And the content of this VoIP(APNs) PUSH was the incoming call at "11:00 AM".
In other words, the VoIP(APNs) PUSH at 11:00 AM is stuck inside iOS, and at 14:55:11 PM, from NetworkExtension reports it.
I feel there is a problem on iOS doesn't handle incoming call of Local PUSH when receiving a Local PUSH after receiving an VoIP(APNs) PUSH.
Would you tell me Apple's opioion about this?
If this is known problem, Please tell me about it.
Dear Apple Engineer
Recently we found that our push delivery rate has decreased. On the website "https://icloud.developer.apple.com/dashboard/notifications/teams/43Y657P48S/app/com.taobao.fleamarket", we found that starting from January 8, 2025, "Discarded - Token Unregistered" showed an upward trend, from millions to tens of millions.
We have not found the reason, and hope you can help us.
Team ID: 43Y657P48S
Bundle ID: com.taobao.fleamarket
Here are some failed tokens, in "Device Token Validator" The query is valid, but the user cannot receive the message:
56025f656cc3aa701898037f59e8d0cb937263ff5585cd1cec9ae661dcc15b19
5fbbd1e604d3662d7583e9377676f8fa276005145278d6dea04b4fc85a7b070e
f0970602551f8d249d8f97960a74006ad78688b52fec6b0d19a585 207caff62e 9388fb40209c100afc2db728342f6fe86c7e34787a8fe4a92b73d2503c5286e0 a2819a4708462588b07452ed827d9afb03c343b586e70dcb67a9981f76295704 8949373cd43783fa3e23d38d55ee1fd72475b39f9c2d2fedca3ecb925b094240
Best Regards!
After upgrading my latest M4 MacBook Pro to macOS 15.2, and even after connecting my iPhone with iPhone Mirroring, there is no 'Allow notification from iPhone' switch option in the macOS notification settings menu, which prevents me from displaying push notifications from my iPhone on macOS.
Hello,
I'am trying to validate a new app from apple.
I have configured sandbox url and production url for server to server apple store notification.
I have created subscriptions product id, but there are no validated yet by apple.
When I upload my app to testflight, I can't test sandbox notification cause the product id are not available, on local xcode with storekit file I got my product Id but I don't receive notification.
So my question is how can I test there thing. I have to produce fake product id ? I'm lock its very complex process, I don't understand.
I tried to send my app like that for verification but the team told me to use receipt, but its deprecated and notification webhook is better for me.
What is the good order, validate my subscription product ID then test ? what is the good steps.
Apple seems to don't want validate my subscription product ID I'm lock..
As you announced at this link https://developer.apple.com/forums/thread/766788, 'APNs will update the server certificates in sandbox on January 20, 2025, and in production on February 24, 2025.' I guess you have updated the sandbox certificate. What can we do to test whether we have correctly updated our application’s Trust Store to include the new server certificate.We test on a server that haven't updated the new server certificate, connect your sandbox environment 'api.sandbox.push.apple.com' to send notifications, it succeed. As I guess, it should failed.
after doing the "Reset all settings" in settings app. After the reset, our app isn't in the notifications menu and in "allow # to access" list, isn't the notifications option either. Reinstall seems to do the job but that's not an optimal solution.
Hello everyone.
I'm trying to add a lifetime for push notifications via apns-expiration for my application.
With the Internet turned on, push notifications come, that's ok.
With the Internet turned off, as I noticed, only the last push with the badge installation on the application icon comes.
That is, the logic is that a text push with text is sent, then after N time the next push to the same device with the badge installation.
I would like to receive a text push after turning on the Internet.
I tried below at 2:00 PM on 21/01/2025(JST).
Apple Push Notification service server certificate update
I followed above,
a new server certificate: "SHA-2 Root : USERTrust RSA Certification Authority certificate" was added to my push server, but a certificate error occurred and push notifications could not be sent.
So I refered this article,Instead of connecting via DNS name resolution at api.development.push.apple.com,
I fixed api.development.push.apple.com to "17.188.143.34" in /etc/hosts,
I could push notifications with the new server certificate.
(I got this IP(17.188.143.34) from this airtcle)
From this, I suspect that Apple had not yet updated the APNs certificate (CA) for the Sandbox environment as of 2:00 PM on January 21, 2025 (JST).
Was the update published as scheduled?
Problem
We have successfully set up push notifications using Apple APN service, that is push notifications work when using a token generated using the JSON Web Token Generator in the Push Notification console. However, we get an "InvalidProviderToken" error when creating using our own token using the following code.
The Key and TeamID is definitely correct (obviously, censored in the below code). When pasting our token in the JSON Web Token Validator in the Push Notification console we get the error „Invalid signing key“. We merely pasted our secret key in our setNewTokenIfNeeded code, separated on four lines using the “““ style.
Does anyone know why this error happens? Given that it works when we upload our .p8 file to the JSON Web Token Generator and we simply paste the text of this file (excluding the lines with "-----BEGIN/END PRIVATE KEY-----") I guess our secret key is correct?
Code to generate token
fileprivate var currentToken: String?
fileprivate var currentTokenCreateTime: Date?
fileprivate func setNewTokenIfNeeded() {
// Ensure, token is at least 20 minutes but at most 60 minutes old
if let currentTokenCreateTime = currentTokenCreateTime {
let ageOfTokenInSeconds = abs(Int(currentTokenCreateTime.timeIntervalSinceNow))
NSLog("Age of token: \(Int(ageOfTokenInSeconds / 60)) minutes.")
if ageOfTokenInSeconds <= 20 * 60 { return }
}
// Generate new token
NSLog("Renewing token.")
let secret = """
ABCABCABCABCABCABCABCABCABCABCABCABC+ABCABC+ABCABCABC+ABCABCAB/+
ABCABCABCABCABCABCABCABCABCABCABCABC+ABCABC+ABCABCABC+ABCABCAB/+
ABCABCABCABCABCABCABCABCABCABCABCABC+ABCABC+ABCABCABC+ABCABCAB/+
ABCABCAB
"""
let privateKey = SymmetricKey(data: Data(secret.utf8))
let headerJSONData = try! JSONEncoder().encode(Header())
let headerBase64String = headerJSONData.urlSafeBase64EncodedString()
let payloadJSONData = try! JSONEncoder().encode(Payload())
let payloadBase64String = payloadJSONData.urlSafeBase64EncodedString()
let toSign = Data((headerBase64String + "." + payloadBase64String).utf8)
let signature = HMAC<SHA256>.authenticationCode(for: toSign, using: privateKey)
let signatureBase64String = Data(signature).urlSafeBase64EncodedString()
let token = [headerBase64String, payloadBase64String, signatureBase64String].joined(separator: ".")
currentToken = token
currentTokenCreateTime = Date()
}
fileprivate struct Header: Encodable {
let alg = "ES256"
let kid: String = "ABCABCABC" // Key (censored here)
}
fileprivate struct Payload: Encodable {
let iss: String = "ABCABCABC" // Team-ID (censored here)
let iat: Int = Int(Date().timeIntervalSince1970)
}
extension Data {
func urlSafeBase64EncodedString() -> String {
return base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
}
}
Code to send the push notification
func SendPushNotification(category: ConversationCategory,
conversationID: UUID,
title: String,
subTitle: String?,
body: String,
devicesToSendTo: [String]) {
// Für alle Felder s. https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification
let payload = [
"aps": [
"alert": [
"title": title,
"subtitle" : subTitle ?? "",
"body": body
],
"category" : category.rawValue,
"mutable-content": 1
],
"conversationID": conversationID.uuidString
] as [String : Any]
// Ggf. Token setzen
setNewTokenIfNeeded()
guard let currentToken = currentToken else {
NSLog("Token not initialized.")
return
}
NSLog(currentToken)
// Notification an alle angegebenen Devices schicken
let bundleID = "com.TEAMID.APPNAME"
for curDeviceID in devicesToSendTo {
NSLog("Sending push notification to device with ID \(curDeviceID).")
let apnServerURL = "https://api.sandbox.push.apple.com:443/3/device/\(curDeviceID)"
var request = URLRequest(url: URL(string: apnServerURL)!)
request.httpMethod = "POST"
request.allHTTPHeaderFields = [
"authorization": "bearer " + currentToken,
"apns-id": UUID().uuidString,
"apns-topic": bundleID,
"apns-priority": "10",
"apns-expiration": "0"
]
request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: .prettyPrinted)
URLSession(configuration: .ephemeral).dataTask(with: request) { data, response, error in
if let error = error {
NSLog(error.localizedDescription)
}
if let data = data {
NSLog(String(data: data, encoding: .utf8)!)
}
}.resume()
}
}
On a similar note, some people seem to encounter this error when using the prettyPrinted option for the JSON serialization (i.e., in request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: .prettyPrinted). Could this be the culprit, given our secret key contains „/„ and „+“?
Many thanks!
i got some problem for the LiveAcitvity when i start it with notification.
The LiveActivity can not show,but it can work when i update or end a LiveActitvity;
And so,i think my configeration is right like the code;
thanks in advance
Background:
① We initiate push notification requests by generating tokens using the p8 certificate.
② The lowest version of the server we use is Ubuntu 16.04, and the image is Alpine Linux 3.15.
③ Currently, the root certificate USERTrust_RSA_Certification_Authority.pem is default in the system and has the same MD5 value as the provided download file. The time for both is 2019.
My questions:
① Which certificate should we download and add to the server's trust store, Root Certificates?
② Does the system we are using default include this certificate?
③ What operations are needed for this server certificate replacement?
Hello, it seems like starting from iOS 18.0, it is possible to entirely skip the notifications permission request alert by swiping up from the bottom of the screen. It doesn't work this way with any other kinds of system alerts, nor in iOS 17.4 (tested it in the Simulator though).
So, is it a bug? Or is it intended? Either way, I haven't found any information regarding that.
The problem with that is when you skip the alert, notifications are missing from the app preferences.
We integrated App Store Server notification, to get notified about CONSUMPTION_REQUESTS and REFUND notifications.
In the data, we noticed same transactionId have multiple REFUND decisions, usually REFUND_DECLINED and then REFUND. Why is that? Did user contact customer support ?
For the second (or later) REFUND decision, CONSUMPTION_REQUEST notifications are usually not sent, but thats not always the case. Sometimes, REFUND decision are the same. Sometimes, we get even 3 or more REFUND related notifications for same transactionId, e.g:
2024-12-02: REFUND_DECLINED
2024-12-05: REFUND_DECLINED
2024-12-12: REFUND
Do user request refund again ? Do they contact customer support ? But I can not explain why sometimes status it REFUND at first, but then later REFUND_DECLINED.
Thank you already in advance:)
Currently, our company server is using the push service by calling APNS through the p8 certificate.
In this process, our server does not have a CA certificate or SSL certificate in use.
Only the p8 certificate is installed and only performs the role of calling APNS.
If it is used like this, is there no need to update the CA certificate separately?
Or do I have to apply a new SSL certificate and add the CA to it?
Can someone help me plz?
On December 6, 2024, I received the following email.
Does this mean that there is something that needs to be done on the app side or on the Firebase side?
Currently, in our project, we are using Firebase to set up push notifications.
If anyone knows how to deal with this or has taken any action, could you tell me what specific steps you took?
Action Required: Apple Push Notification Service Server Certificate Update
As we announced in October,
the Certification Authority (CA) for Apple Push Notification service (APNs) is changing.
APNs will update the server certificates in sandbox on January 20, 2025,
and in production on February 24, 2025. To continue using APNs without interruption,
you’ll need to update your application’s Trust Store to include the new server certificate: SHA-2 Root : USERTrust RSA Certification Authority certificate.
To ensure a smooth transition and avoid push notification delivery failures,
please make sure that both old and new server certificates are included in the Trust Store before the cut-off date for each of your application servers that connect to sandbox and production.
At this time, you don’t need to update the APNs SSL provider certificates issued to you by Apple.