UPDATE:
So I discovered that if UIScreen.main.traitCollection.userInterfaceStyle is called in a notification service extension then it doesn't detect any change to the iPhones light/dark mode unless the phone is restarted.
(I tried with other extensions, changes are detected immediately in other extensions, however not with a notification service extension nor in a notification content extension).
ORIGINAL POSTING:
I've got a notification service extension which is populating the notification with images before it's displayed.
The images are part of an image set with different images for light and dark modes.
What I've discovered is that which image is displayed in the notification depends upon whatever mode the phone was in when the app was installed or when the phone was restarted and it will stay like that for any subsequent posted notifications forever regardless of what the phone's light/dark mode setting is, unless the phone is restarted.
Here's an example to illustrate what I mean, here's an image set in the Media.xcassets for the extension, its called "Grunt".
And here's some code in the extension:
notificationContent!.title = "GRUNT"
if let url = URL(forImageResource: "Grunt") {
do {
let attachment = try UNNotificationAttachment(identifier: "imageAttachment", url: url)
notificationContent!.attachments = [attachment]
} catch {
NSLog("error")
}
}
contentHandler(notificationContent!)
When the app is installed, if the phone is set to light mode, then when a notification is posted the 2x Light image is displayed in the notification. If the phone's setting is then changed to dark, then the 2x Light image still continues to displayed in all subsequent notifications that get posted.
Conversely, if the phone is set to dark mode when the app is installed then the 2x Dark image is displayed in a notification, similarly if the phone's settings are changed to Light, the Dark image continues to be displayed for any new notifications posted.
Until the phone is restarted - then any new notification display in accordance with whatever the phone's dark mode is set to at the time the phone is restarted.
In other words, if the phone's light/dark mode setting is changed, new notifications posted don't display the appropriate light/dark image from the image set unless the phone is restarted.
(Occurs with both iOS 16 and 17)
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
Hello everyone,
I have been working on a macOS app that utilizes push notifications for the past year. Up until recently, everything was functioning correctly. However, now I'm experiencing issues where push notifications are either not being delivered at all or are experiencing significant delays, sometimes up to 10 minutes. Setting the priority header to 10 hasn't made any difference. I am currently using development push notifications, but the issue persists when switching to the production environment.
I'm curious if anyone else has encountered similar problems. When checking the push console, it frequently reports that the device is offline, even though it's actually online ("discarded as device was offline"). Occasionally, notifications are delivered promptly, but this is becoming increasingly infrequent.
This issue has been consistently reported by our testers, particularly after they updated to macOS Sonoma. Any insights or assistance you can provide would be greatly appreciated.
We are experiencing issues with transmitting MDM push.
Some are successfully transmitting, but the majority are failing.
The following message occurred on the server:
java.util.concurrent.ExecutionException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: api.push.apple.com/2620:149:208:430f:0:0:0:a:443
java.util.concurrent.ExecutionException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: api.push.apple.com/2620:149:208:4303:0:0:0:b:443
java.util.concurrent.ExecutionException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: api.push.apple.com/2620:149:208:430c:0:0:0:b:443
java.util.concurrent.ExecutionException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: api.push.apple.com/2620:149:208:430b:0:0:0:a:443
java.util.concurrent.ExecutionException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: api.push.apple.com/2620:149:208:4303:0:0:0:b:443
java.util.concurrent.ExecutionException: io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: api.push.apple.com/2620:149:208:4306:0:0:0:d:443
Apple system status was normal.
Since some are successfully transmitting, we suspect that the issue may not be related to the network.
I'm going to apply the Location Push Service Extension function to the app I'm currently developing.
It's still in the development stage, and it hasn't been uploaded to TestFlight.
When request permission for the Location Push Service Extension feature, it says App Store url is required.
Can this feature be added after the app is deployed to the App Store?
I tried to test it through CloudKit, but the CLLocationPushServiceErrorDomainError3" error occurred in CLLocationManager's startMonitoringLocationPushes method, so I can't test it either.
struct NetworkImage: View {
let url: URL?
var body: some View {
Group {
if let url = url, let imageData = try? Data(contentsOf: url),
let uiImage = UIImage(data: imageData) {
Image(uiImage: uiImage)
.resizable()
}
else {
Image("league")
}
}
}
}
NetworkImage(url: URL(string: context.attributes.imageGame))
.aspectRatio(contentMode: .fill)
.frame(width: 35, height: 35)
.clipShape(Circle())
I have an app that schedules a handful of local notifications with trigger dates 1 to 4 weeks in the future. Each notification has a single image attachment with a JPEG sourced from the app's main bundle.
In development builds via Xcode, or builds via TestFlight, the notifications do appear in the notification center and they do display an image. However, in App Store builds, the notifications appear, but they do not display an image.
I have ruled out the following:
Images may not be included in the bundle
Images may be too large or unsupported (they are ~50KB 480x480 JPEGs, and the docs say validation happens at scheduling time)
The iOS device may have no free disk space
I'm leaning towards either:
Differences in file protection in App Store builds (though the docs say the app process must have access to the image and images in the bundle are copied)
The notifications are scheduled too far in the future and if the image is copied from the bundle to temporary storage, it gets wiped before display
Does anyone have any insight?
Sample code to schedule the notification below:
let dateComponents = // Some date in the future
let content = UNMutableNotificationContent()
content.title = // Some title string
content.body = // Some body string
content.userInfo = // Some app-specific dict
if let path = Bundle.main.path(forResource: "my-image-file-name", ofType: "jpg") {
let url = URL(fileURLWithPath: path)
do {
let imageAttachment = try UNNotificationAttachment(identifier: "", url: url) // Note the empty string identifier - the docs say one will be provided.
content.attachments = [imageAttachment]
} catch {
print("Failed to add image to local notification")
}
}
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
let request = UNNotificationRequest(
identifier: "my-notification-id-here", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request) { error in
if let error = error {
print("Failed to add notification request: \(error)")
}
}
I have made an app to test flight, and I am using Push Notifications Console by apple, and all I need it how to get the hexadecimal bytes that identify the recipient's device. (Device Token) to be able to send push notifications. I just want to send it to all users at the same time.
APNs Notification Receive time on Apple Watch
Connected with iPhone
approximately 10-15 seconds
Without Connection with iPhone
Immediately (less than a single second)
Does anyone know why the situation that I've wrote above?
Hello,
I am reading up on the documentation and seems to have some discrepancies but wanted to double check.
In Overview for PTChannelManager, it states "Multiple calls to channelManager(delegate:restorationDelegate:completionHandler:) result in the system returning the same shared instance, so store the channel manager in an instance variable." https://developer.apple.com/documentation/pushtotalk/ptchannelmanager
However if we look at the documentation for creation of a channel manager,
in the completionHandler, it states that it will return "A new channel manager instance."
https://developer.apple.com/documentation/pushtotalk/ptchannelmanager/4031737-channelmanager
So is it a shared instance that gets returned or will a new instance be created? Need to know if we will need to implement a multiDelegate Pattern or not for this scenario for example if someone else called this function, would they take over the callbacks or would they get their own instance?
Thank you.
Push notification is enabled on my Mac app and the APN message is being received, didReceiveRemoteNotification being called however notification didn't show up in the notification center. And when I checked the System->Notifications, my app is not even being listed in Application Notifications. Please kindly advise.
Hi.
Anyone knownn if there is some update or something APPLE done so that i cant get notifications and sound when i try so send information to my app, it has worked until two days ago.
Hello.
It seems that some customers are having a problem receiving Push notifications sent by our app.
There is only one transmission history on the server.
Some users receive only one notification, while others receive multiple notifications.
There are no in-app notifications, and all notifications are sent from the server.
Given this situation, we believe that there may be a problem on the OS side that receives the push notifications.
We would appreciate any solutions or information you can provide.
As an example, we will send you information on the actual push notification where the duplication occurred.
This is occurring on iOS16 as well as iOS17.
Thank you.
regards.
===
Payload:
{
"aps": {
"alert": {
"title": "",
"body": "{body}"
}
},
"nd_custom": {
"tap_location_url": "{url}", }
"send_no": "861917"
}, }
"show": "1"
}
Date and time of transmission:
Nov 10, 2023 23:00:03
===
Is it possible to pick the user's current device tone/sound as the Push Notification sound for my app programmatically. So that s/he does not miss out any notification just because of unsustainable sound.
I have gone through the UNNotificationSound Class, it provides the option to opt either the default or the custom sound. But, my concern is to auto pick the sound which user is using on his/her mobile.
Thanks in advance!
We are using the below getPushToken() function to retrieve live activity token. However there are cases in production such that await activity.getPushToken() never finish. i.e. have logs of start event and no return or end event, the code path stuck at the guard statement.
Do anyone face same issue and if can advise what can go wrong and how best to handle such cases?
// log start event
guard let pushToken = await activity.getPushToken(),
!pushToken.isEmpty else {
// log return event
return
}
// log end event
extension Activity {
public func getPushToken() async -> String? {
for await data in pushTokenUpdates {
return data.map { String(format: "%02x", $0) }.joined()
}
return nil
}
}
Hello!
We have issue with updating multiply widgets of one kind.
For my case we have widget with one setting (period), and it will be common case for user to use two widgets of one kind to see data for two periods. Also user need to sign in our app to see info on widget.
After installing app we add 2 or 3 widgets of one kind on home screen. Now widgets saying what we need to sign in. We tap on widget, signing in, app sends WidgetCenter.shared.reloadAllTimelines(). When we going to home screen.
One widget updated and showing data and another non-updated and saying what we need to sign in
Why did Apple change the sound for Notifications in iOS 17??? I just finally upgraded today from iOS 16.7.2 to iOS 17.1.1 and among other things I don't like, this one makes no sense whatsoever! Why can't user select the sound we want for Notifications? At least when I had the Tri-Tone sound I could hear it. The new sound is way too quiet, causing me to miss notifications now.
PLEASE FIX THIS ASAP!
I want to send APN to update a pass in the Wallet app.
Followed this guideline.
https://developer.apple.com/documentation/walletpasses/adding_a_web_service_to_update_passes#3733254
I tried with Typescript (Firebase Functions) like this.
var path = "/3/device/"+pushToken
var url = "https://api.push.apple.com:443"+path
const response = await fetch(url, {
method: 'POST',
body: null,
headers: {
'apns-topic': 'com.colorfull.walletPass',
'apns-push-type': 'background',
'connection': 'keep-alive'
}
});
Got this error.
TypeError: fetch failed
Tried with Flutter like this.
var path = "/3/device/$pushToken";
var url = "https://api.push.apple.com:443$path";
Response resp = await post(Uri.parse(url), headers: {
'apns-topic': 'com.colorfull.walletPass',
'apns-push-type': 'background',
'connection': 'keep-alive'
}, body: {});
Got this error.
ClientException: Invalid request method, uri=https://api.push.apple.com/3/device/688a3d6bf83526f00f6fb3d8dd197578f665dea0eeba7aebbe68c61f06bad198
Obviously I'm doing it all wrong, but there is no clear guideline.
How can I send APN??
Our app get strange things
Server send push once
but App get received message twice or more (same)
is APNS OK?
This is for Google Workspace to Apple Push certificates
Finish APNS certificate setup
Upload the certificate you downloaded from Apple
File attached
MDM_ Google LLC (Ent)_Certificate (3).pem
We uploaded the certificate received from the Apple Push Certificates Portal but keep coming up with an error message:
The certificate didn't upload
Hello all,
We are using APNs to send push notifications to mobile apps using token-based connection (using .p8 certificate) and the technical certificate signed by Apple authority (which we have included in our truststore)
The technical certificate was retrieved from push.apple server using the following commands:
Sandbox env
echo -n | openssl s_client -connect api.sandbox.push.apple.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/api.sandbox.push.apple.com.crt
PRD env
echo -n | openssl s_client -connect api.sandbox.push.apple.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/api.sandbox.push.apple.com.crt
Now, the time has come to renew the technical certificate before it expires ( validity period of 2 years), and we face the situation where we get the same certificate back from the push.apple server.
√ /tmp [09:53] # openssl x509 -noout -text -in 'api.push.apple.com.crt'
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
17:97:52:80:2d:4d:48:bb:e5:ed:25:94:49:da:6d:63
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=Apple Public Server RSA CA 12 - G1, O=Apple Inc., ST=California, C=US
Validity
Not Before: Dec 19 17:22:50 2022 GMT
Not After : Jan 18 17:22:49 2024 GMT
Subject: CN=api.push.apple.com, O=Apple Inc., ST=California, C=US
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
We all know PRD releases do take time, and we expected new certificates to already be available on the push.apple server.
Critical Problem: The PRD application will fail all our business use cases, as it will fail to successfully connect with Apple using a trusted SSL connection
How can we proceed further?
Thank you!