twilio-conversations-demo-ios-swift icon indicating copy to clipboard operation
twilio-conversations-demo-ios-swift copied to clipboard

System messages causing app to crash

Open pBread opened this issue 2 years ago • 2 comments

Twilio Conversations assigns the "system" identity to messages created without an author. This means that some ConversationMessage records will have an identity but no participantSid.

The schema for the ConversationMessage in this app requires a participantSid property. When you attempt to view conversations with system messages, the app crashes with the log "NSLocalizedDescription=participantSid is a required value" and Xcode brings you to line 64 of ConversationsApp/Models/CoreData/CoreDataManager.swift.

Here is screenshot of Xcode during a crash

Screen Shot 2023-10-11 at 3 29 28 PM

Steps to Reproduce

  1. Log into the app
  2. Create a conversation
  3. Grab the conversationSid from the Twilio Console
  4. From the command line, create a message in the conversation with the "author" property undefined, like so...
curl -X POST "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages" \
--data-urlencode "Body=System test" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
  1. Go back to the app, open the conversation with the system message
  2. The app should crash

pBread avatar Oct 11 '23 21:10 pBread

Related to #17

berkus avatar Oct 12 '23 13:10 berkus

just make the participantSid attribute as Optional. It is located in Models -> CoreData -> ConversationsApp -> Entities (PersistentMessageDataItem) click on participantSid and on the right panel click on Optional. Save. Run.

hcossio avatar Jan 26 '24 03:01 hcossio