I am developing an app which makes use of actionable notifications.
On my code (the func userNotificationCenter function), I need to read my users from the local storage on the iPhone:
let query: [String: Any] = [
kSecAttrService as String: "uio-auth",
kSecAttrAccount as String: "users",
kSecClass as String: kSecClassGenericPassword,
kSecReturnData as String: true
]
var result: AnyObject?
SecItemCopyMatching(query as CFDictionary, &result)
let ref = result as? Data
But when the same code execute when I tap on the notification on the Apple Watch, it doesn't fetch anything. It now occurs to to me:
Does it mean that when an actionable notification programmed for the iOS is displayed on the Apple Watch, it tries to access its own storage, and not the iPhone? If so, is there a nice way to pass the values to the watchOS so that when the callback for the actionable notifications run, it has then the data it needs?
Notification Center
RSS for tagCreate and manage app extensions that implement Today widgets using Notification Center.
Posts under Notification Center tag
63 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Somebody help me please.
I try to set specific time for notification, it works nice, but if you need a little beat more functional this is where difficulties appear. I'd like to give opportunities for repeat, example every hour. I know that UNCalendarNotificationTriger has a repeat value, but when you set repeat on true it remember date component, exp - .minute, and then just repeating notification every time when that minute comes!
I'm looking for solution for set notification at special time(exp: 5:00 pm), and then repeating this notification every hour(6, 7, 8, 9 pm)
Maybe it's so easy but looks like I feel stuck 😕
With apple intelligence enabled I am seeing a 10-15 sec delay in push notification.
This is actually causing issue with my alarm system, door bells and 2FA requests.
I'm using iPhone 16 Pro.
First installed 18.1 Dev beta 5 and AI and noticed this.
When beta 6 was released it continued.
I put in FB15389900.
My app uses custom notifications with custom images. Why do these images get mixed up with those from other apps, causing my notifications to display images from other apps?
`INImage *avatarImage = [INImage imageWithImageData:imageData];
NSPersonNameComponents *nameComponents = [[NSPersonNameComponents alloc] init];
nameComponents.nickname = content.title;
INPersonHandle *handle = [[INPersonHandle alloc] initWithValue:nil type:INPersonHandleTypeUnknown];
INPerson *messageSender = [[INPerson alloc] initWithPersonHandle:handle
nameComponents:nameComponents
displayName:content.title
image:avatarImage
contactIdentifier:nil
customIdentifier:customIdentifier
isMe:NO
suggestionType:(INPersonSuggestionTypeNone)];
INSpeakableString *speakableString = [[INSpeakableString alloc] initWithSpokenPhrase:content.subtitle.length ? content.subtitle : @""];
INSendMessageIntent *intent = [[INSendMessageIntent alloc] initWithRecipients:@[messageSender]
outgoingMessageType:(INOutgoingMessageTypeOutgoingMessageText)
content:content.body
speakableGroupName:speakableString
conversationIdentifier:identifier
serviceName:nil
sender:messageSender
attachments:nil];
[intent setImage:avatarImage forParameterNamed:@"speakableGroupName"];
INInteraction *interaction = [[INInteraction alloc]initWithIntent:intent response:nil];
interaction.direction = INInteractionDirectionIncoming;
[interaction donateInteractionWithCompletion:nil];
UNNotificationContent *_content = [content contentByUpdatingWithProvider:intent error:nil];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
content:_content
trigger:trigger];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:completionHandler];`
I created a local notification as follows:
func scheduleNotification(title: String, subtitle: String = "", date: Date, id: String) {
// Extract the components from the date
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minute = calendar.component(.minute, from: date)
let second = calendar.component(.second, from: date)
// Set the extracted components into DateComponents
var dateComponents = DateComponents()
dateComponents.hour = hour
dateComponents.minute = minute
dateComponents.second = second
let content = UNMutableNotificationContent()
content.title = title
content.subtitle = subtitle
content.sound = UNNotificationSound.default
let action1 = UNNotificationAction(identifier: Constants.NOTIFICATION_ACTION_IDENTIFIER_1.id, title: Constants.NOTIFICATION_ACTION_IDENTIFIER_1.label, options: [])
let action2 = UNNotificationAction(identifier: Constants.NOTIFICATION_ACTION_IDENTIFIER_2.id, title: Constants.NOTIFICATION_ACTION_IDENTIFIER_2.label, options: [])
let category = UNNotificationCategory(identifier: "reminderCategory", actions: [action1, action2], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
content.categoryIdentifier = "reminderCategory"
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger)
// add our notification request
UNUserNotificationCenter.current().add(request)
}
and I also have
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// Handle foreground presentation options
completionHandler([.sound, .badge])
}
but for some reason the notification only shown on the phone. I've made sure that the phone is locked, apple watch is unlocked and also the notification setting in the watch app for this app is set to mirror.
Hey all!
During the migration of a production app to swift 6, I've encountered a problem: when hitting the UNUserNotificationCenter.current().requestAuthorization the app crashes.
If I switch back to Language Version 5 the app works as expected.
The offending code is defined here
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
FirebaseConfiguration.shared.setLoggerLevel(.min)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { _, _ in }
application.registerForRemoteNotifications()
Messaging.messaging().delegate = self
return true
}
}
The error is depicted here:
I have no idea how to fix this.
Any help will be really appreciated
thanks in advance
I am trying to use onNofitication in BehaviorComponent to fire up my composed timeline actions. Which is formed up by one TransformTo action, one Hide action and followed by a Notification action indicating the other two actions are finished.
With this post, I successfully send a notification to RCP to fire up my timeline with identification:
NotificationCenter.default.post(
name: NSNotification.Name("RealityKit.NotificationTrigger"),
object: nil,
userInfo: [
"RealityKit.NotificationTrigger.Scene": scene,
"RealityKit.NotificationTrigger.Identifier": "onSomethingStart"
]
)
On the other hand, to subscribe that Notification Action, I append a onReceive function below my RealityView, and succesfully received my notification
private let notificationTrigger = NotificationCenter.default.publisher(
for: Notification.Name("RealityKit.NotificationTrigger"))
guard let entity = out.userInfo?["RealityKit.NotificationTrigger.SourceEntity"] as? Entity,
let notificationName = out.userInfo?["RealityKit.NotificationTrigger.Identifier"] as? String else { return }
debugPrint("Received notification: \(notificationName), entity name: \(entity.name)")
Which means that my Timeline is fired up because I can received my notification in my Timeline.
But the rest two actions just don't appear to be working. I played the timeline in RCP it works fine.
Anything I missed to make it tick?
XCode beta 16.1
VisionOS beta 9
Currently if the app is hidden and locked behind face id even though the notifications are not displayed but the Notification Service Extension still wakes up for the notification.
Is it the expected behaviour ? Or should we expect the NSE would not be used as well when the app is hidden.
I can execute an action by allowing Xcode to send a notification to Reality Composer Pro via NotificationCenter, or I can send notifications to Xcode through the Notification Action in Reality Composer Pro. However, I discovered that they were unable to accept notifications from both parties within my project. To ascertain whether there was an error in my code, I created a simple Demo project. I utilized the same code and determined that it functioned normally within the Demo project. It is perplexing that I am unable to resolve this issue. Do I require additional modifications?
I have triggered few notifications, and they were delivered to my iPhone with a delay of several hours. Could you please assist us in resolving this issue?
Device: iPhone 15
OS Version: 17.5.1
I understand that TodayExtension will be deprecated in iOS 18, and we have integrated WidgetKit into our app. However, we have encountered some issues during the app update process. Specifically, we noticed that the TodayExtension might not appear in the tools list or sometimes the TodayExtension appear "Unable to Load"
Could you please advise on the possible causes of this issue? Is there a way to resolve it if we want to keep both types of widgets active?
For notifications, I am using a firebase api [cloud messaging ].
I am getting normal notifications in all app states. when I try notifications with the attached image URL, in the foreground the image is displayed and it working properly but when the application is in a background state or terminated the normal text notification is getting without image.
I also tried using the ns-notifications service and contents.
Hi Apple Team,
Am seeing that in Apple's "share watch face" documentation that ClockKit APIs are still being used to share watch faces.
So my question is - will those ClockKit APIs (and therefore ClockKit complications) be supported in watchOS 11? Thank you.
Good afternoon! I am working on an app which requires the app to be opened in response to a push notification from a background state. As it stands:
The app is running in the background
The app has a static widget on the homepage
The app has a dynamic widget with a live activity which is being updated from the backend
The dynamic widget is firing an event which the static widget is listening for
The static widget is programatically calling an AppIntent which tries to open the parent app
Is this possible? Is there a better approach which would work?
We are looking for a way to open the app from the background with the users permission. Appreciate any guidance on the issue
I'm trying to start a live activity that allows a user to see and control a recording from their lock screen. I have an AppIntent that uses a class to start recording the user. The intent is used in a home screen widget. Upon pressing the button in the widget, the intent is called, which then calls the startRecording function within its perform.
This function then tries to start the live activity, but it is currently failing with a "Failed to start live activity: The operation couldn’t be completed. Target does not include NSSupportsLiveActivities plist key" error.
The relevant code block is this:
func startRecording() {
print("[RecordingManager] start recording called")
isRecording = true
let activityAttributes = RecordingControlWidgetAttributes(name: "RecordingManagerActivity")
let initialContentState = RecordingControlWidgetAttributes.ContentState(isRecording: true, startTime: Date())
let initialContent = ActivityContent(state: initialContentState, staleDate: nil)
if ActivityAuthorizationInfo().areActivitiesEnabled {
do {
liveActivity = try Activity<RecordingControlWidgetAttributes>.request(
attributes: activityAttributes,
content: initialContent,
pushType: nil
)
} catch {
print("Failed to start live activity: \(error.localizedDescription)")
}
} else {
print("Live activities are not available")
}
// TODO: actually start the recording
}
When this function is run/the button is pressed, the following messages are printed:
"[RecordingManager] start recording called
Failed to start live activity: The operation couldn’t be completed. Target does not include NSSupportsLiveActivities plist key"
However, I have included the NSSupportsLiveActivities key, with value YES, in the target Info in XCode for both the main app target and the WidgetExtension.
The following line exists in both the Release and Debug parts of the project.pbxproj file:
INFOPLIST_KEY_NSSupportsLiveActivities = YES;
I also tried including this key and value directly in the Info.plist file of both targets, but that also didn't work.
This issue is occurring both on device and in simulator. I also checked that both my device and the simulator has LiveActivities turned on in Settings for the app.
What could be going wrong? Are there any other situations where this error may print?
Tried all these steps
Force restart
DIsabled focus mode
Notifications are enabled in both device and in app settings
Disabled summary notifications.
Tried sending notification from pusher tool, that also is not showing up in the center, for the device effected but on another device it is working fine for the same application(same version too)
What could be the reason and a possible solution?
Tried all these steps
Force restart
DIsabled focus mode
Notifications are enabled in both device and in app settings
Disabled summary notifications.
Tried sending notification from pusher tool, that also is not showing up in the center.
What could be the reason and a possible solution?
I'm a macOS app developer, and I'm facing an issue with custom notification sounds in my app. After upgrading the app to include new custom notification sounds, the changes do not reflect until the system is restarted. The sounds do not update immediately after the app upgrade.
Is there a way to refresh or reload the custom notification sounds without needing a full system restart? Any guidance or best practices to handle this would be greatly appreciated.
Thank you!
Hello,
I'm a macOS app developer, and I'm facing an issue with custom notification sounds in my app. After upgrading the app to include new custom notification sounds, the changes do not reflect until the system is restarted. The sounds do not update immediately after the app upgrade.
Is there a way to refresh or reload the custom notification sounds without needing a full system restart? Any guidance or best practices to handle this would be greatly appreciated.
Thank you!
hi, I am trying to schedule a UNNotificationRequest at a certain date using UNCalendarNotificationTrigger, and I also want to update the badge count accordingly. However the badge property in UNNotificationContent can only be set when adding UNNotificationRequest, not when the trigger is fired or notification is actually delivered. How can I set up-to-date badge count if notification is scheduled in the future?
For example, if I scheduled notification A to 3 hours later with badge count 1, and in between I got notification B, badge count should be 2 when A is delivered but it will be 1.
I am aware of didPresent delegate which can be used when app is in foreground when notification is delivered, but is there any delegate that is called when UNNotificationRequest is delivered and app is backgrounded or we are using NSE? Thanks.