Question about iOS Extensions implementation


We are trying to develop a Share Extension for our app that will allow users to send images, videos and URLs from their device via share sheet in other apps.

Same like how you can share photos from your photo library to WhatsApp, Messenger, Telegram, etc.

I have a few questions regarding this:

  1. Is it possible to make CometChat share it’s container so that I can access and get the value of the currently logged in CometChat user in the host app? If I call the getLoggedInUser, it returns nil even though the users is loggedIn in the host app.

  2. Is it possible to use the REST API in iOS instead of the SDK as an alternative?

  3. Is there any difference between sending a message via SDK vs sending a message via REST API? I believe the latter does not require any authentication from the user as long as you pass the API Key and app ID?

Hello @jeraldo,

Here are my comments on your queries.

  1. SDK’s user object is stored in the local db which is not possible to share with background extensions provided by iOS. To share uid of the logged-in user you can store it in the userSuite and then you can share that uid with share extension. You must need to set app groups for the same.

  2. Yes. You can use rest APIs for communication, but using rest AP’s you won’t be able to maintain real-time communication. This will result in your real-time messaging won’t work if you implement it via rest API.

  3. There is no difference in sending messages via SDK or rest API, SDK internally using the same rest API only.

Thanks @pushpsen.airekar.

Is there any plan to support sending messages to multiple recipients (text/media message)? This feature is available in the REST APIs as I’ve checked and tested.