NotificationCenter

RSS for tag

Create and manage app extensions that implement Today widgets using NotificationCenter.

NotificationCenter Documentation

Posts under NotificationCenter tag

74 Posts
Sort by:
Post not yet marked as solved
0 Replies
42 Views
I'm Facing an issue when i Debug Project in Real Device, I'm Getting Notification With Custom Sound, But After making a Build Via Diwai, I'm Not Getting Custom Sound, It Play Default Sound with Notification.I'm Using Firebase. I have Added Custom Sound in Project and added in Bundle Resources as well. Please Have A look on My Code. Here's My Code func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. let content = UNMutableNotificationContent() content.sound = UNNotificationSound(named:UNNotificationSoundName(rawValue: "EigenIntro.caf")) FirebaseApp.configure() Messaging.messaging().delegate = self if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.current().delegate = self let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization( options: authOptions, completionHandler: { _, _ in } ) } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) application.registerUserNotificationSettings(settings) } Messaging.messaging().token { token, error in if let error = error { print("Error fetching FCM registration token: \(error)") } else if let token = token { print("FCM registration token: \(token)") } } application.registerForRemoteNotifications() return true } func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { print("Firebase registration token: \(String(describing: fcmToken))") self.sendDataToServer(token: fcmToken!) } func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { let userInfo = notification.request.content.userInfo print(userInfo) completionHandler([[.alert, .sound, .badge]]) } func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { let userInfo = response.notification.request.content.userInfo print(userInfo) completionHandler() } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let token = deviceToken.hexString print("APNs Device Token: \(token)") Messaging.messaging().apnsToken = deviceToken Messaging.messaging().setAPNSToken(deviceToken, type: .prod) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Messaging.messaging().appDidReceiveMessage(userInfo) completionHandler(.noData) }
Posted
by jinal.
Last updated
.
Post not yet marked as solved
0 Replies
41 Views
AVFoundation have these notifications like AVCaptureDeviceWasConnected, AVCaptureDeviceWasDisconnected, AVPlayerItemDidPlayToEndTime, AVPlayerItemFailedToPlayToEndTime, etc., that inform if a device was connected or disconnected, if the video paused, stop, ended, etc. Is there some similar for airdrop? I means if files are airdropped, which files were airdropped, etc? I need to receive a list of files that were airdropped to macOS when that happens. Is that possible to know that, by notifications or other means?
Posted
by LunarBase.
Last updated
.
Post not yet marked as solved
0 Replies
53 Views
In my iOS/iPadOS app I have notification content extension, which presents extended content using WKWebView. However, when started on lock screen (locked device), WKWebView does not load data properly. Therefore, I would like to ask user to unlock the device before displaying content. This is how Apple Mail does that - when selecting (long-pressing) notification banner on lock screen, it presents unlock screen (Passcode screen) before displaying content. Question: Do you know, how to do that? Is there any API to present unlock screen programmatically?
Posted
by kpuchar.
Last updated
.
Post not yet marked as solved
0 Replies
74 Views
I want to open Instagram by clicking on the button in the expanded push notification. To do this, I use the following line: extensionContext.open(URL(string:"instagram://")!) in the button action. When I click on the button, a warning may appear about transition to another application. After the alert I can go to the app and it works perfectly. But if I try to go to instagram from Notification Center or through a locked screen, nothing will happen. Although a warning about the transition will appear, Instagram doesn't open if you click confirm. Does anyone know how to fix this? P.S. is it possible to somehow remove the alert of transition to another application?
Posted
by PillowMan.
Last updated
.
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 Last updated
.
Post not yet marked as solved
1 Replies
332 Views
I would like to implement notifications about NSPersistentCloudKitContainer I find this classe but I receive no notifications in my app!?! Do I need more settings to use it? thanx for your help import Combine import CoreData @available(iOS 14.0, *) class SyncMonitor { /// Where we store Combine cancellables for publishers we're listening to, e.g. NSPersistentCloudKitContainer's notifications. fileprivate var disposables = Set<AnyCancellable>() init() { NotificationCenter.default.publisher(for: NSPersistentCloudKitContainer.eventChangedNotification) .sink(receiveValue: { notification in if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event { // NSPersistentCloudKitContainer sends a notification when an event starts, and another when it // ends. If it has an endDate, it means the event finished. if cloudEvent.endDate == nil { print("Starting an event...") // You could check the type, but I'm trying to keep this brief. } else { switch cloudEvent.type { case .setup: print("Setup finished!") case .import: print("An import finished!") case .export: print("An export finished!") @unknown default: assertionFailure("NSPersistentCloudKitContainer added a new event type.") } if cloudEvent.succeeded { print("And it succeeded!") } else { print("But it failed!") } if let error = cloudEvent.error { print("Error: \(error.localizedDescription)") } } } }) .store(in: &disposables) } }
Posted
by docgg.
Last updated
.
Post not yet marked as solved
2 Replies
203 Views
Is there any way to run code in iOS whenever new information are added to certain contacts in contact store? If I use Notifications, I would have to have a process running at all times, since contacts are able to be changed by Apple's Contacts app. I have looked at App Extensions and there are no extensions I that can be used. There is a way to run a background process but I recall that has a limited lifespan. Am I correct about this? I need to update data in CloudKit that saves contacts information that can be shared with other users using their own Apple ID's. CloudKit subscriptions notify my app when something changes in CloudKit, but I also need to update records in CloudKit when something changes in Contacts. Anyone have any ideas how this might possibly be done?
Posted Last updated
.
Post not yet marked as solved
11 Replies
7k Views
Hello. After the ios14 update, there was a problem that the application I distributed did not request notification permission. In ios 13.7 version, notification permission is normally requested, but the device that has updated ios 14 does not request notification permission. When requestAuthorization outputs the error details to completionHandler, the following error is displayed. =========================================== Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application} =========================================== If you know how to fix it, please let me know. Have a nice day.
Posted
by NIKM.
Last updated
.
Post not yet marked as solved
0 Replies
163 Views
Hello everyone! I am trying to implement push notifications in my WatchOS app. I have created the delegate class that handles the registration for remote notifications and that allows me to obtain the device token. Then I take the token and send it to Firebase, like this: func didRegisterForRemoteNotifications(withDeviceToken deviceToken: Data) {     FirebaseApp.configure()     var ref: DatabaseReference!     ref = Database.database().reference().ref.child("/")     let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }     let token = tokenParts.joined()      if let userID = UserDefaults.standard.object(forKey: "id") as? String {         ref.child("users/\(userID)/token").setValue(token)     } } Then I am using a Python Script to communicate with APNS. I am using the http library to get access to HTTP2. This is what I have got: payload = { "aps" : { "alert" : { "title" : "Hello Push", "message": "This is a notification!" }, "category": "myCategory" } } dev_server = "https://api.sandbox.push.apple.com:443" device_token = "9fe2814b6586bbb683b1a3efabdbe1ddd7c6918f51a3b83e90fce038dc058550" headers = { 'method': 'POST', 'path': '/3/device/{}'.format(device_token), 'autorization': 'bearer' + 'provider_token', 'apns-push-type': 'myCategory', 'apns-expiration': '0', 'apns-priority': '10', } async def test(): async with httpx.AsyncClient(http2=True) as client: client = httpx.AsyncClient(http2=True) r = await client.post(dev_server, headers=headers, data=payload) print(r.text) asyncio.run(test()) I have also downloaded the .p8 auth key file. But I don't really understand from the Apple Documentation what I have to do with it. What is the provider token in the headers? Am I doing the right thing with the token I receive from didRegisterForRemoteNotifications?
Posted
by tmsm1999.
Last updated
.
Post not yet marked as solved
2 Replies
153 Views
good day, I need help with see below when the notification is OK, the badge is added. If the application is opened the badge disappears. that is right. when a new notification arrives badge it is not 1 but the value is previous value +1. I need the value to be 0 when the application is opened. it's about resetting the badge value. I don't know if this code Is correct for my functionality. func applicationDidBecomeActive (_ application: UIApplication) { UIApplication.shared.applicationIconBadgeNumber = 0 } the value does not reset but only disappears.
Posted
by Radim007.
Last updated
.
Post not yet marked as solved
0 Replies
182 Views
It has appeared 3~4times on different ios15 phones. when app not running, provider push two notifications(background+ normal). the notification service extension logs that the normal push was received, but banner not present and tone not alarm, app not awaked(there is no problem with the settings on the device). when lanch the app manually about 30s later, app logs that the background push received("application:didReceiveRemoteNotification:fetchCompletionHandler" called). It seems that ios system block or delay handle the remote notifications, has anyone encountered the same problem?
Posted
by jhshao-24.
Last updated
.
Post not yet marked as solved
0 Replies
147 Views
Hi Team , I am facing an issue with one of the scenario in Actionable Push Notification. Case: On long press of notification , we get two actions "Accept" and "Review". On click of Accept , an api call triggers. If the API call is success we don't have to do anything but if the api call fails , we have to open the app and redirect the user to specific screen on app. There is a option to get the app on foreground on click on Accept Button, since app should not open on click of accept button but it should open when the api call gets fail on click on accept button that option is of no use. Another option I tried is to use openURL method, that also doesn't work when the app is in background How can I solve this ?
Posted
by abhisi123.
Last updated
.
Post not yet marked as solved
0 Replies
177 Views
Problem: Need to create an app (General) that will start/stop and manage other apps (Secondary). The general app will be only one, but secondary apps will be as many as user want. As well the general app should communicate with secondary apps. PS: The secondary app MUST start only as a separated instance app. Question: I want to know your thoughts, adviсes, and best practices for: Should I create one Xcode project with two targets (General and Secondary)? Or should I create two different Xcode projects? As for me: maybe one of the best solution will be the second one with using some ci/cd. What do you think? How the general app should communicate with second apps? As for me: Could Distributed Notifications helps in this situation? Thank you, I will be glad for any information, word, or sources.
Posted
by Anton.Ye.
Last updated
.
Post not yet marked as solved
0 Replies
164 Views
Hello there, I'm using firebase to push notification with data is: { "notification": { "title": "Title notification", "category": "GENERAL", "body": "body notification", "sound": "default" }, "mutable_content": true, "data": { "title": "Title message", "body": "Body message.", "idhit": "a043dada-1208-4067-b5b6-50bc8578bfc3", "gmtdatetimeid": "620989200", "typehit": 0, "carnumber": "ABC123", "alertname": "Unauthorized Vehicle", "gmtDatetime": "2020/06/05 07:28:30.929", "latitude":"10.792332496703715", "longitude":"106.68018372088815" }, "registration_ids": [ "eBStmdlNfUzJghm1KwpKr-:APA91bGcqODroQnUKKOvJmlg3Vs1ej9Zq-" ] } when my app receive data, i want to get GPS of device and compare it with gps from notification. How do did it, thanks!!!
Posted Last updated
.
Post not yet marked as solved
0 Replies
268 Views
I am trying to add time sensitive notifications to my task/reminder app, but I am having some difficulty. Here is the code I am using currently: let center = UNUserNotificationCenter.current() let content = UNMutableNotificationContent() content.title = "Productivi" // that's the name of the app content.body = "\(taskObject.content)" //task content content.categoryIdentifier = "TASK_REMINDER" if #available(iOS 15,*) { print("Using ios 15 for set notification") content.interruptionLevel = .timeSensitive } For the adding notification request, that part works, however when the notification shows up, it isn't a time sensitive one. (I was testing in simulator and on my phone both running iOS 15.4) I can't figure out what else there is I have to do in order to enable the feature. I've done everything it says to do, is their an entitlement or capability I have to add. If so, what is it called and can some one please give me detailed steps on how to add that for local notifications in XCODE? Thank you, -Rohan
Posted
by roroCoder.
Last updated
.