twilio / twilio-conversations-demo-ios-swift

Twilio Conversations for iOS Demo application in Swift
MIT License
17 stars 19 forks source link

System messages causing app to crash #18

Open pBread opened 1 year ago

pBread commented 1 year ago

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
  5. Go back to the app, open the conversation with the system message
  6. The app should crash
berkus commented 1 year ago

Related to #17

hcossio commented 9 months ago

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.