About Local Notifications
The IMLib SDK does not implement local notification functionality. You need to implement local notifications at the business layer.
- When the app first enters the background, it remains in an active background state. The SDK receives messages through the persistent connection channel, triggering message reception callbacks. You can display local notifications when receiving these callbacks. For details about message listeners, see Receiving Messages.
- After the app stays in the background, system limitations cause the IMLib SDK's persistent connection to disconnect after a maximum of 2 minutes. If the connection times out or the app is suspended by the system, it will actively disconnect. Any subsequent messages will be delivered via APNs push notifications.
Due to the inherent business characteristics of Ultra Groups, apps may need to implement granular local notification control strategies in conjunction with Do Not Disturb Levels (see Ultra Group Do Not Disturb Overview).
Currently, the IMLib SDK's API for retrieving Do Not Disturb settings is asynchronous and fetches from the database each time, which may cause delays that don't meet some apps' requirements for local notification handling. If you need to retrieve Do Not Disturb level data from memory, consider the following implementation approach:
-
Encapsulate a query method at the business layer, such as defining a
checkNotifyAbilityWithmethod for a customRCMessageNotificationHelperclass to determine whether a message should trigger a local notification. -
Maintain a global NSDictionary at the business layer to cache Do Not Disturb information for queried conversations. If the memory lookup fails, perform a database query and update the global dictionary.
-
In the IMLib SDK, you can call the
checkNotifyAbilityWithmethod within the message reception callback (onRCIMReceiveMessage) to check whether the received message should display a local notification.
- (void)onRCIMReceiveMessage:(RCMessage *)message left:(int)left {
[RCDMessageNotificationHelper checkNotifyAbilityWith:message completion:^(BOOL show) {
if (show) {
NSLog(@"[RC] Show");
} else {
NSLog(@"[RC] Hide");
}
}];
}
Local notification display priority logic: Message configuration > App global settings > User-specified group channels > User-specified groups > Conversation type settings > Ultra Group default configuration