Local Notification
The IMKit SDK has implemented the creation, display, and redirection behavior of local notifications, enabling developers to quickly build applications.
What is a Local Notification
A local notification refers to a notification (Notification) created and sent directly by IMKit or the application client by calling system APIs when the app is running in the foreground or background. When the app is in the background and receives a new message, IMKit will display a notification reminder in the notification panel by default, which is a local notification.
IMKit's local notification supports the following scenarios:
-
When the app has just entered the background (still in an active background state), IMKit can still receive new messages through the persistent connection channel (recalled messages will also generate recall signaling messages). By default, this triggers a local notification, and clicking it will redirect to the corresponding conversation page.
tipAfter the app enters an inactive background state (e.g., killed by the system), the IMKit persistent connection is disconnected. At this point, offline push notifications triggered by third-party push services (or RC push) are created and displayed directly by the vendor, independent of IMKit's local notification mechanism.
-
When the app is in the foreground and no conversation page is open (not chatting with anyone), receiving a new message will trigger a ringtone and vibration by default but will not display a notification. You can modify this to silent mode or display only the notification using
setForegroundOtherPageAction. Refer to NotificationConfig.java.