Is it possible to listen/observe for new notifications macOS receives?
I mean like when a new iMessage or a Slack message is received (so basically everything that causes NotificationCenter to display a Notification)
Short answer: It is not possible.
You can't observe user notifications sent by applications unless an application provides a specific API. For example the AppleScript dictionary of iMessage and Mail contains events scripts can respond to. However user notifications are encapsulated in the target application.
There is a global notification class named DistributedNotificationCenter, a notification dispatch mechanism that enables the broadcast of notifications across task boundaries. Some processes are sending distributed notifications but it's a completely different functionality as UserNotification. For example the TimeMachine engine process backupd sends distributed notifications while running a backup.
You can subscribe for all distributed notifications with
DistributedNotificationCenter.default().addObserver(self, selector: #selector(handleNotifications(_:)), name: nil, object: nil)
but I doubt that iMessage sends a distributed notification when a message is received.
Related
I've integrated Huawei's Pushkit, push notification service into my Xamarin application, I've tested the notifications while the application is running in the foreground and it works as expected.
However, while the application is closed the application and attempt to send a notification, the OnMessageReceived method in my messaging service is not triggered.
According to the documentation that can be found here :
Regardless of whether your app is running in the foreground or
background, if you override the onMessageReceived method in the
DemoHmsMessageService class, your app can obtain the data message
content as long as you send a data message.
According to me, that means the OnMessageReceived method should be triggered, so long as you're sending a Data Message.
Am I missing something, or did I perhaps misinterpret the above-quoted passage?
Thanks In Advance! ๐
Push kit supports two types of messages - notification messages and data messages.
OnMessageReceived will be triggered for data message to receive message.
For data message, if app is closed, user might not receive message. As per doc :
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/funtion-description-0000001050148080
The delivery of data messages depends on the resident status of your
app. Push Kit cannot guarantee a high data message delivery rate,
because it may be affected by Android system restrictions and whether
the app is running in the background.
It might be because of battery optimization.
For Notification message, notification can be delivered regardless of app resident status, even if app is not launched.
Do we have any alternative for chatting app becuase iOS silent push notifications are highly highly unreliable, for example
if the app was terminated by the user they are not delivered at all
if the battery power is <= 40%, the OS receives the push but often delays delivering it to the app for a few minutes
if the batter pwer is >= 20, the OS receives the push but decides not to forward it to the app at all
many other criteria affect whether the OS actually delivers the push to the app or not
We tried using Voip push to achieve smooth chatting behavior for apps not suspended state. But the problem is in iOS 13 its must to report incoming call on voip push arrival.
Do we have any other option or way around so that chatting apps like ours can work in background/suspended state (for short time)?
If your server has all the information you need to write the notification text, you can send regular push notifications that won't wake up your app.
There's no other way than using silent push notifications to run your app in background, but one alternative is to use Notification Service app extension. It won't wake up your app, only this app extension, but you'll be able to write code for it to modify the notification text before presenting it to the user
It's possible to share data between your app and this extension - by sharing the database or just some data using app groups or the keychain. Your app extension will only have 30 seconds to run, but that should be enough.
Silent push notifications are unreliable and should not be used to notify about a new message.
VoIP pushes are exclusive for reporting incoming calls.
I need to cancel some of scheduled push notifications via API.
Not via web console.
For example, it will be good to have ability to cancel all of scheduled push notifications for specific deviceToken (filter by deviceToken will be good enough, because I donโt need to cancel specific pushes).
REST API doc have nothing on this topic.
This is not possible at the moment, the only two ways are to either use the Push Dashboard in a browser, which can be unhandy if you schedule a huge amount of notifications or to implement your own queuing system for Push notifications.
The latter would involve creating a new table for your notifications and a background job that will send out all notifications that are due to be sent. Once sent, remove them from that table.
Other than that, you're out of luck at the moment.
I have created a Push Notification service for my IOS app using the code from the link below.
http://woutercx.com/2013/05/09/sending-push-notifications-iphone-with-pushsharp-csharp-monotouch-client-server-side/
I have coded every thing and set up the certificates correctly for push notification in my IOS app.
The question is how do I schedule the push notification to be sent to the registered IOS devices periodically. Lets say I want my users to be notified every hour? In short i do i make use of the methods of Pushsharp to schedule a Remote notification at a specified intervals.
Since pushsharp is a library, not a service, it has no ability to send notifications periodically or delay them. The library is only able to communicate to APNS (apple push notification service). APNS does not provide the ability to delay/repeat notifications, so neither does the library.
If you need to send notifications basing on time (say, hourly), you have to set up your own service that will wake up hourly and post a notification to devices that need it. I'm afraid there is no other way to do it without external services.
In a project I'm currently working on, we send some small info across the wire to WP7 device when we send a raw notification.
When the application is in a tombstone state and the user receives the toast message, we can't add the extra baggage in the toast. So we figured we need a way to resend the notification once the user entered the application again.
Anybody has any experience or possible solution for this problem. We are currently looking at a sort of handshaking between client and server. But it all seems a bit drastic for me.
Kind regards,
Tom
I would suggest to stop using rawNotifications and use only toast.
To handle the case when the app has been started using a toast notification, query the server at app startup to check if there's pending data.
For notifications sent while the app is running, you can detect them using the ShellToastNotificationReceived event of your channel. When the event is triggered, query the server to retrieve the payload.