Currently, in my app number of lines for a title and sub-title in a notification is only one.
Is there a way to customize the number of lines for a title and sub-title like how we cusomize it in the expandable mode?
User Notifications
RSS for tagPush user-facing notifications to the user's device from a server or generate them locally from your app using User Notifications.
Posts under User Notifications tag
159 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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.
Dear Apple,
The decision to NOT allow us to change the notification tone and to NOT allow us to increase the volume so that we can hear it means that as a stock trader I’m NOT getting the ACTIONABLE ALERTS I need during the day. PLEASE CHANGE THIS SO THAT I CAN: 1) increase the volume and 2) assign different notification tones to different applications and 3) make it so that I have the option of including VIBRATION with my notification.
THANK YOU.
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)")
}
}
Hey everyone,
I'm currently programming a chat app with SwiftUI, Firestore & optionally OneSignal.
But I'm currently having the problem that I don't receive push notifications when I'm not in the app.
External push messages that are triggered, for example, via the OneSignal website are also displayed in the backround.
I just can't get it triggered in the app, does anyone have a code or a suggestion for me?
Best regards
Max
Hi everyone,
I have two questions regarding some issues with the new iOS 17 interactive widgets and live activities.
Question 1: How can I update other Widgets and/or Live Activities, based on an AppIntent interaction in either one?
I have several widgets that is displaying the same information, but in different sizes (Small, Medium, Large and Lockscreen). Most of our users are using many of them together on their Lockscreen and Home Screen. When they are interacting with the AppIntent button in either the Widget og LiveActivity it does not update and vice-versa.
Based on the documentation it's pretty clear that interacting with a Widget it will update the timeline for that specific widget after the .perform() in the AppIntent is returned. Unfortunately, I also need to update the LiveActivity and the other TimeLines for the rest of the widgets. I have tried to use the WidgetCenter.shared.reloadAllTimelines() but it seems like it does not update the LiveActivity or the LockScreen widgets correctly.
Question 2: How can I update and reschedule the local notifications based on the interaction in the Widget and Live Activity?
The app sends a local notification whenever an activity starts or stops (e.g like a pomodoro timer with intervals). Let's assume the user have setup a 30 minute activity in the app, but now decides to pause the activity from either the widget or live activity. I then want to remove the scheduled local notification that was supposed to be fired in 30 minutes. I haven't been able to read from the documentation if this is possible, but would like to know if there is any way this can be performed.
Looking forward to hear if anyone have encountered the same challenges :)
Hey everyone,
I'm facing the following issue:
I'm using one signal as a push notification service, and I want to create two projects: staging (especially to test some backend notifications) and production.
For production, I can attach the .p8 file and then we're good.
For staging, if I attach the same .p8 file, I would be in trouble because I can send a notifications to a real user even being on staging environment.
How should I proceed in this situation?
how can I set the notification to be sent for like every 3 days with a future start date?
please help me
Hi all,In our application we Use VoIP Type push notifications to give a heads-up for the mobile phone.This allows the mobile phone to:1) If the application is killed, start it in background2) If the application is in Background, start running the application statemachine3) If the Phone is in deep sleep, Wake up and start the application in BackgroundDue to the above, our application arrives in a state where we can receive an incoming voip Call.It has been observed that there is a delay in the push notification arrival at the mobile phone.Delayed arrival/delivery of Push notification has been measured of about 6 sec or sometimes never arrives.This espicially is the case when we have an iPhone without sim-card.Note :- This was tested on a controlled setup with large number of iterations with good WiFi and internet connectiviy)- We ensured during testing that the push was actually dispatched to APNS.It is unknown as to what exactly causes a variation in the arrival of the voip notification.Can someone explain why :- Voip messages arrive late depite they should be 'instant' ?- What could explain the difference in measurments with/without sim card ?Best regards.
Our card is added to wallet app, and now we have updated our app icon. But wallet app show old icon on notifications. This doesn't happen for newly added card. Only happens to older added cards (before icon update).
Is there a way to let wallet app to update the icon for older cards.
Hi,
If we implement actionable notifications on iOS, the buttons corresponding the actions are displayed on the Apple Watch as well.
I wonder if I could detect that the button was tapped on the Apple Watch or on the iPhone, so I could react to it differently.
Hello all. I face problem with Notification Service Extension. User mobile receive notification without any problem, payload contain mutable-content:1 inside it ( also, full example of payload is attached ), but, NSE didn't run correctly, also, original content of notification didn't saw ( in case, and there is a crash because of something wrong in app )
I checked device logs, and I see next errors:
[*] Mutated notification request is nil, will supress original content; notificationRequest=7019-8D60, error=Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 487 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 487 on anonymousListener or serviceListener}, runtime: 0.410339
[*.notificationextension] Service extension connection encountered an error: sessionUUID=88D39801-67DF-4DC7-AA70-2AD7E8634369, error=Error Domain=NSCocoaErrorDomain Code=4099 "The connection from pid 505 on anonymousListener or serviceListener was invalidated: client is gone." UserInfo={NSDebugDescription=The connection from pid 505 on anonymousListener or serviceListener was invalidated: client is gone.}
example of payload:
"aps": {
alert = {
"loc-args" = (
msisdn
);
"loc-key" = "key";
};
badge = 1;
"content-available" = 1;
"mutable-content" = 1;
sound = "pnsound.aiff";
}, "m": CFG, "j": msisdn, "t": id, "n": M]
This problem is face from time to time, I can't catch this problem on same build and same environment, also, this problem can occur for some time, and after that everything will be fine
Hi all,
As part of development for my app I'm wanting to utilise the Apple Push Notification service. For now, I have implemented the necessary code in an app delegate class which you can see below
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Request permission to display alerts and play sounds.
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
if granted {
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
}
}
// Set the delegate for the UNUserNotificationCenter
UNUserNotificationCenter.current().delegate = self
return true
}
// MARK: - APNs Registration
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
let token = tokenParts.joined()
print("Device Token: \(token)")
// Send or save this token as necessary.
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register for remote notifications with error: \(error.localizedDescription)")
}
// MARK: - UNUserNotificationCenterDelegate Methods
// Called when a notification is delivered to a foreground app.
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.banner, .sound])
print("message received!!")
}
// Called when a user taps on a notification.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
print("user tapped on banner!!")
completionHandler()
}
// Called when a notification is delivered in the background
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let messageData = userInfo["yourKey"] as? [String: AnyObject] {
print("Background Notification received!!")
print(messageData)
completionHandler(.newData)
} else {
completionHandler(.noData)
}
}
}
To test this, I've just been using the terminal Like so:
curl -v \
--header "authorization: bearer $JWT" \
--header "apns-topic: $TOPIC" \
--header "apns-push-type: alert" \
--http2 \
--data '{"aps":{"alert":"Hello from Terminal!", "content-available":1}}' \
$APNS_ENDPOINT/3/device/$DEVICE_TOKEN
However, despite including the "content-available" tag the didReceiveRemoteNotification function is not being called. Any idea why this is? I have made sure that all the necessary capabilities have been included (background fetch, remote notifications).
We have configured the push notification service (Server-provider) to communicate with APNS with hostname: api.sandbox.push.apple.com and Port: 443. APNS request is going successfully but from APNS to device (iPhone 6S ) not coming.
We have whitelisted the above port and other ports also(2195, 2197). but. still not able to receive the notification.
We have also cross verified with the old gateway.sandbox.push.apple.com:2195 and it's working fine but with new api.sandbox.push.apple.com:443, not working.
Could someone from Apple Community help us to get resolved this issue?
Thanks in advance!!
Hello Apple Developers,
I posted my comments 2 weeks ago and was hoping that with enough people making complaints, Apple developers will make a jump and change the push notification back ot allow users to customize it.
It seems like these Apple developers are either tone-deaf or simply do not care about Apple's future.
As a business owner, I can tell you that if you piss off enough Apple's die-hard, loyal users, Apple will go down in history like many other companies.
I am for one who has used Apple products for many years. I have decided that I will not upgrade or buy another Apple product ever.
I understand that Apple has difficult times with product innovation besides moving buttons here and there and call it "new design".
Push notification is not a new invention. It's been working and why fix/change things that worked.
Please fix the damn issue today so we can move on. It's not that complicated.
The code compiles, however it shows the image just like without options:
let options: [AnyHashable: Any] = [
UNNotificationAttachmentOptionsThumbnailClippingRectKey: CGRect(
origin: CGPoint(x: 0.1, y: 0.1),
size: CGSize(width: 0.1, height: 0.1)
)
]
let attachment = try? UNNotificationAttachment(
identifier: image.url,
url: fileUrl,
options: options
)
The documentation says I should use CGRectCreateDictionaryRepresentation but it is not available.
Cannot find 'CGRectCreateDictionaryRepresentation' in scope
Am I missing something?
In this screenshot, instead of the app logo only, there is a image of the person that messaged the user.
I think this is possible by using an INSendMessageIntent with an INPerson. Apple Wallet notifications however, use a similar design.
So should/can we use the INSendMessageIntent with an INPerson for non Message/Person related content? Or is there another way to achieve Apple-Wallets notification style?
I use a UNNotificationServiceExtension to download an image into temporaryDirectory that is attached as an UNNotificationAttachment to the notification.
FileManager.default.temporaryDirectory
.appendingPathComponent(UUID().
.appendingPathExtension(image.ext)
data.write(to: fileUrl)
let attachment = ...
attachments.append(attachment)
The documentation for UNNotificationAttachment say I am responsible to manage the storage space for such attachments:
The system limits the amount of storage space allocated for attachments for each app. To delete attachments, use the methods of the UNUserNotificationCenter class to remove the notification requests that contain those attachments.
https://developer.apple.com/documentation/usernotifications/unnotificationattachment
Do I need to check in my AppDelegate if there are any notifications that are no longer displayed and remove their files?
If so, how how to get a list of notifications that are no longer displayed?
From an MacOS Application, I want to listen for the arrival of push notification event for any app installed on the Mac system.
I understand, AppKIt provides API to listen for receiving push notification of that application. But, Is there any API, which can listen and just notify the developing app when a notification arrived for any apps installed on the system?
Hi there,
Our app is installed on tablets provided to customer workers for performing tasks. We're currently implementing Push Notifications using AWS SNS and FCM. The goal is to send data-only (silent) push notifications to trigger a function that creates a record in the app's local DB.
This approach allows us to control how the message is displayed in the foreground and background using Notifee. While this works well on Android in all states (foreground, background, killed), we're facing an issue on iOS, specifically in the release build.
The silent push notifications only reach devices when the app is in the foreground, not in the background or killed states. Normal push notifications work fine, but we require the ability to send silent notifications for better processing control. Upon researching, we discovered that Apple has strict guidelines for these notifications to prioritize user experience, battery usage, spam prevention, and privacy. However, in our case, the tablets are dedicated work devices with only our app installed.
Given this context, is there a reliable solution to send silent push notifications to iOS devices with the app in the background or killed states?