User Notifications

RSS for tag

Push user-facing notifications to the user's device from a server or generate them locally from your app using User Notifications.

User Notifications Documentation

Posts under User Notifications tag

225 Posts
Sort by:
Post not yet marked as solved
1 Replies
8.3k Views
Hi, I have an app that receives push notification from server with "content-available": 1and i have set my app to increase badge count as soon as it receives push notifications likefunc application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void ) { let badgeNumber = UIApplication.shared.applicationIconBadgeNumber + 1 UIApplication.shared.applicationIconBadgeNumber = badgeNumber }so my app shows badge count correctly in any state (active, background, killed) when it is built in Debug.But my app is not showing badge count when app is in killed state and it is built in Released.(if it is in background mode, badge shows correctly)Is there anyway that I can control badge count from app side (not sending "badge" property through push notification)?All I need to do is, update badge number as soon as app receives push notificationsThanks in advance. Let me know if need more information
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
There's been a longstanding issues with Voip pushes not being delivered to the app if the app has been terminated and the device rebooted PushKit notification not arriving after application kill AND device rebootHowever with iOS 13 I'm seeing that they are not being delivered if the app is terminated without the phone being rebooted (currently observing this on 13.1.3).This is 100% reproducible, but the number of pushes that get delivered to the app after its terminated appears for the first time appears to be variable. Often the app will continue to receive pushes after being terminated but only a few before it stops receiving them entirely. However on some occasions it doesn't receive any whatsoever after being terminated. If the app is launched again then its starts receiving them again BUT only if the app is in the foreground - move it to the background and it doesn't receive any.
Posted
by
Post not yet marked as solved
12 Replies
8.0k Views
I am banging my head. I am implementing push notification. Everything is working fine (push is received, badge is updated) but under iOS 13.3 the method application(_:didReceiveRemoteNotification:fetchCompletionHandler:) is not called when the app is in the background. If the app is in the foreground or using an iOS 12 device the method is called. I register for push notification in the following way (yes, it is still Objective C)[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (granted) { dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication sharedApplication] registerForRemoteNotifications]; }); } }];The payload is set to the following:{"aps": { "badge": 10, "alert": "test", "content-available": 1 }}I tried adding "Remote notifications" and "Background processing" as app capabilities in all variations (only "Remote notifications"/"Background processing", without any of those capabilities, enabling both) without any change. I set the delegate for the UNUserNotificationCenter but again without success. I set the headers accordingly:curl -v \ -H 'apns-priority: 4' \ -H 'apns-topic: xx.xxxxx.xxxx' \ -H 'apns-push-type: alert' \ -H 'Content-Type: application/json; charset=utf-8' \ -d '{"aps": {"badge": 10,"alert": "test", "content-available":1}}' \ --http2 \ --cert pushcert.pem \ https://api.sandbox.push.apple.com/3/device/1234567890From the docs it states that this method is called even when the app is in background:Use this method to process incoming remote notifications for your app. Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background.I tried with and without background modes (Remote Notification, Background processing, Background fetch) but without success. If I use an iOS 12 device, the method is called.My goal is to process some of the information in the payload (there might be additional information).What am I missing here for iOS 13 (13.3 to be exact)?
Posted
by
Post not yet marked as solved
1 Replies
1.5k Views
I am using PHP to send notifications from my server.But it is not working, the program outputs "Unexpected HTTP/1.x request: GET /3/device/myDeviceToken" upon calling curl_exec().No notification is received on my iOS device either.This is the code:token = getToken($keyfile, $kid, $iss); $url="https://api.development.push.apple.com:443/3/device/".urlencode($to); $curl = curl_init(); $headers = array("Content-Type:application/json", "authorization: bearer ".$token, "apns-expiration: 0", "apns-priority: 10", "apns-topic: balintfodor.locationconnection-test"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, true); $options = array($curl, array( CURLOPT_PORT => 443, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $data, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_HEADER => 1, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0 )); $result = curl_exec($curl); $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $err = curl_error($curl); var_dump($httpcode, $result, $err); //int(0) bool(true) string(0) ""
Posted
by
Post not yet marked as solved
11 Replies
3.4k Views
Hi,Since version 2.20.31, released a few days ago, WhatsApp is being built with the iOS 13 SDK, and as such it should have to comply to the new VoIP push notification rules, where an incoming call must be reported to CallKit otherwise the app will be terminated.However we can easily observe from console logs that they are sending VoIP push notifications to awake the app when sending messages from the web client, and that those push notifications not only do not show any native CallKit UI but also keep the app awake long enough to sync with the web client:default 17:09:44.127516+0000 apsd : Received message for enabled topic 'net.whatsapp.WhatsApp.voip' onInterface: NonCellular with payload '{ c = 1; id = 3EB0128F27BBDC904743; t = 1583860183; }' with priority 10 for device token: NO default 17:09:44.146511+0000 SpringBoard Received trusted open application request for "net.whatsapp.WhatsApp" from :343>. default 17:09:44.515731+0000 callservicesd Call source registered with configurationThe logs also mention some type of call source reported but I could not find any related API.From my experience with VoIP pushes, if we don't report the incoming call the app is instantly killed:error 18:56:19.949023+0000 callservicesd Killing VoIP app com.xxxxxx.xxxxxx because it failed to post an incoming call in time.So, how are they doing this? Is there a specific API to report the incoming call as being handled in-app and not requiring the native call UI to be shown? Or are they using some kind of private entitlement that whitelists the app so it doesn't get killed?I'm asking because my app, while fully supporting regular content pushes, we had to drop a web client -like functionality because we could no longer send VoIP pushes to wake the app and reconnect the web socket, and we very much would like to know how we can reactivate it.Thanks in advance for any help.
Posted
by
Post not yet marked as solved
2 Replies
924 Views
Hi guys,I'm experiencing a problem with the apns-expiration header when on Airplane mode.I'm using VoIP notifications to make audio/video call, and each notification has a lifespan of 15 seconds by setting apns-expiration header.This works for most of the cases but I found a case when doesn't work.This case can be reproduced by following next steps:- Mobile data ON with internet connectivity.- Airplane mode ON.- Receiving a VoIP notification with lifespan 15 seconds (when airplane mode ON).- Afer 15 seconds or more, Airpane mode OFF- I get the late (expired) VoIP notification.My guess it's that when we have mobile data ON and we turn airplane mode ON, the internet connectivity it's cut only for the user but Apple keeps it's persistent connection to the APNS server and even on Airplane mode notifications are delivered to the device instantly (if mobile data can reach Internet).And this is a little tricky and I don't know how to handle. I can get a late VoIP ghost call after 1 hour in this particular case. Before iOS 13 this could be handled by not presenting the incoming call to the user, but with iOS 13 we can't do this because “If app repeatedly fails to report an incoming call then Apple will stop delivering VoIP push notifications to the app altogether”.Apns-expiration header works great when I use only wireless connection, or explicitly I turn OFF the Mobile data instead of using Airplane mode.Do you have any insight regarding this problem?Thanks! Have a nice day!
Posted
by
Post not yet marked as solved
1 Replies
363 Views
Hi,we have 3 apps. The push notifications worked properly until the latest IOS update (IOS13.5).The APNS responds with "HTTP200 OK" message but the phone never receives the notifications. It worked on IOS13 but stopped working on 13.5. I also tried to send the json from Apple documentation to make sure it is right but still no luck. I tried with sandbox address and with the live one, both does the same. Responds with HTTP200 but message never delivered.Any suggestion what else to try?
Posted
by
Post not yet marked as solved
1 Replies
891 Views
The use case is enterprise Admin wants to enable/disable Safari Extension without user's involvement. Currently, the onus is on User to enable/disable the extension. In managed endpoint environment, the Admin needs control to enable certain extension silently/automatically (without user's involvement)
Posted
by
Post not yet marked as solved
20 Replies
7.2k Views
Hi There, I'm experiencing some frustration with Bug Sur and I wondered if this is something anyone else has experienced.. Essentially - I've noticed that when the battery goes below 10pc, it doesn't notify you. So, you can be working away in full screen (which I do, frequently) or in the middle of work calls and the Mac just "dies". In Catalina a notification came up saying that your battery was low and to plug it in - but not Big Sur (yet) Please, put this back in - I don't want to have to keep checking my status bar all the time
Posted
by
Post not yet marked as solved
3 Replies
1k Views
My use case : i want the app to completely silence a given received alert push notification, based on information the app has locally (completely remove it, and never even display it. Not just change the sound or badge). So far i found no way of doing that : notification service extension doesn't let you remove the notification entirely, just change its content. Using "background / content" notification type then creating the notification locally doesn't work, since "background" notification type is unreliable by design. voip notifications are banned from being used as a general-purpose background notification mechanism since iOS13 Help would be greatly appreciated.
Posted
by
Post not yet marked as solved
1 Replies
935 Views
We are entitled by Apple for critical alerts. Our app is an alerting app which shall now be used to alert deaf persons. We did not find the possibility to alert deaf persons, by choosing vibration instead of sound. The accessibility options of iOS don't seem to provide an option to choose vibration instead of sound. It does vibrate for a very short amount of time, but it must vibrate for at least 10-20 seconds to be of any help. Is there any possibility to vibrate upon receiving a critical alert notification for that amount of time? We're also using a notification service extension, but we're more interested in an official solution, than a "hack" solution.
Posted
by
Post not yet marked as solved
0 Replies
499 Views
Upgraded ios 13.6 and changed bundle identifier and container name. Created CKDatabaseSubscription for both public and shared database and can see in cloudkit dashboard. Both didFinishLaunchingWithOptions and didRegisterForRemoteNotificationsWithDeviceToken get called in AppDelegate.   UNUserNotificationCenter.current().delegate = self   UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound], completionHandler: { granted, error in           guard granted else { return }     DispatchQueue.main.async {       application.registerForRemoteNotifications()       print("Registered for Remote notifications")             }   })   return true } 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)")   })   self.iCloudSubscribeToPrivateDB()   self.iCloudSubscribeToSharedDB() } In the project both background fetch and remote notifications are enabled. I make databases changes in cloudkit dashboard, but push notifications are not being sent. They were working now just stopped after I made the above changes. What could be wrong?
Posted
by
Post not yet marked as solved
1 Replies
268 Views
Hello everyone, I created reminder with two pickers. One of them is for choose number of days (how often to receive notifications (every 2 days, every 3 days etc.)) and another one for choose the time. Problem is that is two different triggers UNCalendarNotificationTrigger and UNTimeIntervalNotificationTrigger(for Time Interval). Now user can only choose Time Interval. Maybe someone knows how to create both? Thank you:)
Posted
by
Post not yet marked as solved
8 Replies
4.9k Views
Hi Team, I was trying to add NSE to my Project to show Rich messaging. Creation of the NSE target to the project - Successful. Creation of additional provisioning profile in developer portal for NSE and mapped it in XCode - Successful The APS payload contains the content-type: 1 and attachment url to download the media content - Successful. When notification arrive the will present method gets called first - Successful. The auto execution of Notification Service 'didReceive(_ request: UNNotificationRequest,          withContentHandler contentHandler: @escaping            (UNNotificationContent) - Void)' - failure. 6. Tried running the target instead of main app - failure 7. Tried attaching a debugger to get break point - failure 8. Debug and Console logs - failure 9. Additionally tried the below option from every developer suggestion but no luck. o  https://stackoverflow.com/questions/50853503/images-in-ios-push-notification o  https://stackoverflow.com/questions/51722109/unnotificationserviceextensions-didrecieve-not-called o  https://stackoverflow.com/questions/39663903/ios10-unnotificationserviceextension-not-called o  https://stackoverflow.com/questions/46463680/notificationserviceextension-not-called o  https://stackoverflow.com/questions/45483018/unnotificationserviceextension-not-working-on-iphone-5-ios-10 Could you please assist on the same to get it working as the notification service methods cannot be called explicitly and it needs to be triggered by OS. A quick, faster response and resolution is much appreciated.
Posted
by
Post not yet marked as solved
9 Replies
783 Views
I am new to iOS development and I have been a little stuck trying to find some information on continuing a timer in the background. I know that trying to run a timer in the background is not a good idea and that it can yield some unexpected results. I do not actually want the timer object itself to run in the background, but to have its count notify the user that it has completed its interval. I simply want to notify the user by playing a sound or vibrating or both. Then repeat this process again until the user brings the app into the foreground and stops/pauses the timer or closes the app altogether. I do not want to have a local notification appear to the user that the timer is completed. Thank you
Posted
by
Post not yet marked as solved
0 Replies
631 Views
I want to add a category to my push notification and I can't seem to get any success in my attempts. I tried StackOverflow, but nobody responded, so I'm trying here. I thought it would be an issue with my Firebase Cloud Functions message payload, but it's not. I have a function to set a category on my notification when interacted with: func configureCategory() {     let viewAction = UNNotificationAction(identifier: "viewNewEvent", title: "View New Event", options: UNNotificationActionOptions.foreground)     let viewCategory = UNNotificationCategory(identifier: "newEventCategory", actions: [viewAction], intentIdentifiers: [], options: [])     UNUserNotificationCenter.current().setNotificationCategories(Set([viewCategory]))   } I then call this right before application.registerForRemoteNotifications() From, reading many articles, I thought this would work, but my notification just ends up with no actions when i receive it and interact with it. I even decided to create a UNNotificationServiceExtension, and add the identifier in that, but that didn't work either.  override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) - Void) {     self.contentHandler = contentHandler     bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)           if let bestAttemptContent = bestAttemptContent {              bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"       bestAttemptContent.categoryIdentifier = "newEventCategory"               contentHandler(bestAttemptContent)     }   } If anybody knows how to do this properly and sees I'm missing something or placing something in the wrong spot, please point it out and let me know, thanks.
Posted
by
Post not yet marked as solved
4 Replies
614 Views
Hi, I have a LaunchAgent (whose .plist is in /Library/LaunchAgents/ as expected) It is build as a single un-bundled binary, and installed away from regular user access at /Library/MyCompany/executables/ When I try to init a reference to UNUserNotificationCenter: UNUserNotificationCenter *unc = [UNUserNotificationCenter currentNotificationCenter]; I immediately have an exception, like thus: 2021-05-02 19:57:39.297823+0300 agent[12504:225879] *** Assertion failure in +[UNUserNotificationCenter currentNotificationCenter], /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/UserNotifications/UserNotifications-281.6/UNUserNotificationCenter.m:44 2021-05-02 19:57:39.299464+0300 agent[12504:225879] [General] An uncaught exception was raised 2021-05-02 19:57:39.299518+0300 agent[12504:225879] [General] bundleProxyForCurrentProcess is nil: mainBundle.bundleURL file:///Users/mshneor/Library/Developer/Xcode/DerivedData/agent-dgvdlbtivmsjdgdkhhjwaxgrkyht/Build/Products/Debug/ Obviously the problem is bundleProxyForCurrentProcess is nil: mainBundle.bundleURL Now... I could try to bundle my agent somehow, but that's a bit awkward, and I don't know how - it's not an App, and It's not a part of any App, and I don't know about a special "Code Bundle" type (like plugins etc.) that fits a LaunchAgent. Moreover - it will never be "launched" by it's info.plist in the bundle - only via the .plist in /Library/LaunchAgents by launchd. So... is it possible to work around this? Could I somehow tell my Agent's process "Here is our main-bundle" at runtime, and provide a special bundle the agent is not embedded in? what does UNUserNotificationCenter need from main bundle? maybe I can supply this programmatically in advance? Any hint will be greatly appreciated.
Posted
by
Post not yet marked as solved
2 Replies
622 Views
I am trying to use custom sound for local notification on Mac Catalyst. It is working correctly for iPhone/iPad using UNMutableNotificationContent but the same is not working for Mac Catalyst. I have tried playing the custom sound using AVAudioPlayer and it plays correctly so I am assuming it is able to locate the file; the file is stored at Contents/Resources of the app directory. Also the sound file's duration is less than 30 seconds and is saved using .caf format.
Posted
by