From version < 51.24 >
edited by Simon Morlat
on 2020/06/25 18:19
To version < 51.25 >
edited by Simon Morlat
on 2020/06/25 18:21
< >
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -353,17 +353,18 @@
353 353  
354 354  Note: linphone_factory_create_shared_core (factory, config_filename, factory_config_path, system_context, app_group_id, main_core) combines the two steps in a single function.
355 355  
356 -== 3 - Stop the Main Shared Core when going to background ==
356 +==== Stop the Main Shared Core when going to background ====
357 357  
358 -The app extension will need to start an **Executor Shared Core** to get the new messages. To allow that, you need to stop the **Main Shared Core** when the app goes in background. And you need to start it again when the app goes in foreground.
358 +The app extension will need to start an **Executor Shared Core** to get the new messages. To allow that, you need to stop the **Main Shared Core** each time the app goes in background. Reciprocally you need to start it again when the app goes to foreground.
359 359  
360 -- In (void)applicationDidEnterBackground: (UIApplication *)application You need to call linphone_core_stop()
360 +* In //(void)applicationDidEnterBackground: (UIApplication *)application// : you need to call [[//linphone_core_stop//()>>https://www.linphone.org/snapshots/docs/liblinphone/swift/Classes/Core.html#/s:10linphonesw4CoreC4stopyyF]]
361 +* In //(void)applicationWillEnterForeground: (UIApplication *)application// : you need to call [[linphone_core_start()>>https://www.linphone.org/snapshots/docs/liblinphone/swift/Classes/Core.html#/s:10linphonesw4CoreC5startyyKF]]
361 361  
362 -- In (void)applicationWillEnterForeground: (UIApplication *)application You need to call linphone_core_start()
363 +==== Migrate all the configuration files to the shared file system (optional) ====
363 363  
364 -== 4 - Migrate all the configuration files to the shared file system ==
365 +This section is applicable to apps using liblinphone before Xcode 11 arrived.
365 365  
366 -You have created a **Main Shared Core** instead of the usual **Core**. Now all the configuration files need to be moved to the **shared file system**in order to still have the account configured, the messages received in database, the list of the call history, etc.
367 +You have created a **Main Shared Core** instead of the usual **Core**. Now all the configuration files need to be moved to the **shared file system **in order to still have the SIP account information, the call logs, and the conversation history, etc.
367 367  
368 368  For this we use these three functions:
369 369  
... ... @@ -373,27 +373,45 @@
373 373  
374 374  - const char *linphone_factory_get_download_dir(LinphoneFactory *factory, void *context) that leads to /Library/Caches/
375 375  
376 -These functions return paths to the different iOS application configuration directories. It can be used to migrate files to the shared memory because of the context parameter. If context = NULL, the returned path is in the application file system. If context = AppGroupId, the path leads to the file system shared between the app and the app extension.
377 +These functions return paths to the different iOS application configuration directories, depending on the context argument. If context = NULL, the returned path is in the application file system. If context = AppGroupId, the path leads to the file system shared between the app and the app extension.
377 377  
378 -== 5 - Set up the app extension to get the message ==
379 +==== Set up the app extension to get the message ====
379 379  
380 -The function didReceive() of the **NotificationService** app extension will be called when a **Remote** push notification is received. It has ~~30 seconds to get the message before the user notification is displayed.
381 +The function didReceive() of the **NotificationService** app extension is called when a **Remote** push notification is received. It has ~~30 seconds to get the message before the user notification is finally displayed by the system.
381 381  
382 -An Executor Shared Linphone Core is required to retrieve the message. It is created as in step 2 but by setting main_core=FALSE. The main app can stop the Executor Shared Core if it is running when the user put the application in foreground.
383 +Please note that the push notification body must contain two string attributes (in its dictionary):
383 383  
384 -Then you can call:
385 +* call_id : the call_id of the SIP MESSAGE carrying the IM, when the push notification is related to a message.
386 +* chat_room_addr : the SIP address of a chatroom in which the user is being INVITEd, when the push notification is related to an INVITE to join a user to chat room.
385 385  
386 -- LinphonePushNotificationMessage *linphone_core_get_new_message_from_callid(lc, call_id) : to get the message from the //call_id// which comes from the push notification payload.
388 +These are strong requirements. Flexisip proxy server of course takes care of adding these attributes since version 2.0.
387 387  
388 -- LinphoneChatRoom *linphone_core_get_new_chat_room_from_conf_addr(lc , chat_room_addr) : to get the new chat room from the //chat_room_addr// which comes from the push notification payload. This allows the app extension to tell its user when he has been added to a chat room.
390 +An **Executor Shared Linphone Core** is required to retrieve the message. It is created as in step 2 but by setting main_core=FALSE. The **main shared core** running in the main application can stop the **Executor Shared Core** when the user puts the application in foreground.
389 389  
390 -**IMPORTANT NOTES**
391 -\\- Don't call linphone_core_start() yourself. The functions above will start the Shared Core if needed.
392 -\\- It is your responsibility to call linphone_core_stop() (if the Core is not started, it won't do anything). This allows the app extension to perform some actions using the Shared Core after receiving the message but it is better to stop the Shared Core as fast as possible to allow the other instance of NotificationService extension to process. One instance of the app extension is launched for every push (i.e. message) received. The synchronization is done in the Linphone-sdk.
393 -\\- These functions work when the application is in background AND in foreground. So, you can remove your code in the main application that handle messages notifications. The app extension will display ALL the messages to the user.
392 +These two methods are useful to perform the tasks of the app extension:
394 394  
395 -== 6 - Adding actions in user notifications: UNNotificationContentExtension ==
394 +- [[LinphonePushNotificationMessage *linphone_core_get_new_message_from_callid(lc, call_id)>>https://www.linphone.org/snapshots/docs/liblinphone/swift/Classes/Core.html#/s:10linphonesw4CoreC23getNewMessageFromCallid6callIdAA016PushNotificationE0CSgSS_tF]] : to get the message from the //call_id// attribute embedded in the push notification payload.
396 396  
396 +- [[LinphoneChatRoom *linphone_core_get_new_chat_room_from_conf_addr(lc , chat_room_addr)>>https://www.linphone.org/snapshots/docs/liblinphone/swift/Classes/Core.html#/s:10linphonesw4CoreC26getNewChatRoomFromConfAddr04chatfI0AA0eF0CSgSS_tF]] : to get the new chat room from the //chat_room_addr// attribute embedded in the push notification. The app extension can use this information to indicate to the user that has been invited into a new chat room.
397 +
398 +(% class="box infomessage" %)
399 +(((
400 +Don't call linphone_core_start() yourself. The above two functions will start the Shared Core if needed.
401 +)))
402 +
403 +Once ever of the two functions has returned, linphone_core_stop() must be called, in order to allow the core to perform additional actions that usually follow the receiving of a message, such as sending a delivery notification (IMDN), and finally release the shared core lock, to let other push notification to be processed by other notification service extension instances.
404 +
405 +(% class="box infomessage" %)
406 +(((
407 +iOS launches a new instance of the app extension for every push notification received. Proper synchronisation between these multiple instances and the main shared core is performed by liblinphone internally.
408 +)))
409 +
410 +These two methods used by the app extension work when the main application is in background or in foreground. This means that the main application does not need to manage incoming messages. **The app extension will take in charge the notification of ALL the incoming messages to the user.**
411 +
412 +If the application existed before XCode 11, it was probably user local notification to show IMs: this code needs to be removed now that the app extension is handling incoming IMs.
413 +
414 +==== Adding actions in user notifications: UNNotificationContentExtension ====
415 +
397 397  We have implemented the UNNotificationContentExtension app extension in addition of the UNNotificationServiceExtension. We use it to **reply** and **mark as seen** new messages.
398 398  
399 399  The user notifications displayed by the NotificationService extension needs a NotificationContent extension to add a **NotificationCategory**as well as some **actions** attached to this category. The categories and actions declared in the main app won't work when the app is in background.