Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

What if sending a message failed? #25

Open
jyounus opened this issue Aug 25, 2016 · 4 comments
Open

What if sending a message failed? #25

jyounus opened this issue Aug 25, 2016 · 4 comments

Comments

@jyounus
Copy link

jyounus commented Aug 25, 2016

Hey,

I was wondering what happens if a message fails to send? For example iMessage and WhatsApp show an exclamation mark next to the message where the user can manually retry to send it.

Is there something similar for NMessager that's already been implemented? I'd use it if the message failed to send for whatever reason (no internet/backend down/internal server error/whatever).

Thanks

@atainter
Copy link
Contributor

atainter commented Aug 25, 2016

You can do whatever you want with a message if you have a reference to it. There is a footerNode you can set on any MessageNode which might be perfect for this use case. I would probably do something like this:

func sendMessage(text: String) {
        let textContent = TextContentNode(textMessegeString: text)
        let message = MessageNode(content: textContent)

        var footer = ASTextNode()
        footer.attributedText = NSAttributedString() //text indicate sending

        message.footerNode = footer

        MessageService.sharedInstance.sendText(text, completion: { (error) in
            if error {
                footer.attributedText = NSAttributedString() //text indicate error
                message.footerNode = footer
            } else {
                footer.attributedText = NSAttributedString() //text indicate delivered
                message.footerNode = footer
            }
        }
    }

You could also subclass the MessageNode to add tap to retry functionality.

@jyounus
Copy link
Author

jyounus commented Aug 25, 2016

Fair enough, I think the footer would be the perfect place to show the "delivery status" (sent/user received message/user read message).

But for errors, I think it would be much more elegant if it was closer to the native functionality like here in this screenshot:

Screenshot

It indents the bubble slightly and then shows an icon. Tapping on it would fire off a retry callback.

What do you think? This would be great if it was supported for all of the different bubble types (text based, images, collections etc).

How difficult would that be to implement right now? Do you see any issues with this? (I haven't messed around with NMessenger much, but I'm planning to use it soon, so I've no idea how much effort that would be together with ASDK).

@atainter
Copy link
Contributor

I don't think it would be too difficult to implement it, but I'm not sure when we'll get time to do it. @DavidSchechter might be interested in working on it. For now, though, you could use the avatarNode property on MessageNode (see example "MessageGroups"). It's in the correct place and has a delegate method for touch events. The only issue with using this is that it would not have an animation when set.

@jyounus
Copy link
Author

jyounus commented Aug 26, 2016

Thanks for the info. I guess the avatarNode workaround is not a bad idea at all.

Would be great if David wants to work on such a functionality and also make it animatable. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants