New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Message Formats #7
Comments
Do you have an example as to what the button would do or look like? My initial thought is that using text that could control the title or action that you’d need. Though I think there is a case here for a new custom type that accepts Any type. |
Thanks for the response. Sure, my ultimate goal is to have clickable text that looks like a link, but is not a link to a webpage - instead, clicking on the text should trigger an in-app action. I was thinking that I would need a custom type that can store both the text that should be displayed in the message bubble (e.g "Hello") as well as the event that should be triggered on press (e.g a popup). |
Yeah that makes sense. I'll look to add an additional case in that will be accessible by custom message cells. For now you could use a delimiter and split it to get the title and the event e.g. "Hello|popup". Not ideal but for the time being it should work. |
Sounds great. Would there be no way for me to add this kind of custom cell myself though in the meantime? I was trying to see how the text/emoji etc. are defined to replicate them, but could't quite find where they were defined and used. |
Every It should just be a case of adding https://github.com/steve228uk/MessengerKit/blob/master/MessengerKit/Models/MSGMessageBody.swift |
Thank you! 😃I'll play around and let you know! Just one more question if you don't mind - I was trying to add another button beside the "send message" button, but was unable to find how to do so. I was looking in MSGInputView.swift but could not replicate how the "send" was created, do you think you could briefly point me in the right direction when you get a chance? |
Currently |
Gotcha. Very sorry for all the q's, please excuse my incompetence here! May I just ask what is an XIB? |
XIB/NIB is an interface builder file. |
Thank you for all the answers! I appreciate your time. |
Success with "add custom button to the inputView" sir ? @svmadiraju Hope you can share some of your code, really appreaciate it! |
@svmadiraju I've added a Alternatively you could override |
Will add an example later today or tomorrow if I get time. |
Wow, thanks @steve228uk! That was fast, let me take a look and play around with it! Small side note, do you know how to make a new .XIB file for use correctly? Every time I do so and change the file name in |
@svmadiraju You'll need to create a custom UIView and Nib, wire them up and then set the in your style assign it to the https://github.com/steve228uk/MessengerKit/wiki/Creating-a-Custom-Style |
Hi @steve228uk, I'm pretty sure my thick skull is just missing basic something here, but I can't seem to understand what I should modify to add custom elements to the existing style. My incompetence would truly appreciate some guidance in this direction. (Just to clarify, I am trying to modify the message text field + send button "input view" component.) |
@svmadiraju Do you mean custom the message bubble ? I can help share my code. Did success with that. About custom "Input View" same with you, still confuse. |
@svmadiraju @gersonjanhuel For the input view you'll need to subclass the |
Hi @steve228uk, Just following up on the earlier issue I was struggling with. First of all, thank you very much for the clarification. I spent a lot of time with the code and now have a much better understanding of NIBs and all the major files used in MessengerKit and how they work together. I created a new custom InputView as a subclass of However, I am receiving an I spent a lot of time researching this error but can't seem to find anything up-to-date and relevant that could help, so I was wondering if you might be familiar with it. Is there anything further I need to do to link my custom NIB with the project? |
@svmadiraju Could you paste the UINib(nibName: "YourCustomNib", bundle: nil) |
@gersonjanhuel It looks like you haven't linked your UINib to the |
its already linked to MSGInputView... @steve228uk My steps :
|
@gersonjanhuel It should be linked to your new subclass. Try removing the reference and creating it again. |
when I create new outlet in my new subclass... its error... says textView cannot be override... @steve228uk |
@gersonjanhuel You shouldn't need to create the outlet in the file itself as it will be auto-inherited from the super. Right click on the button or text view and drag the outlet to the "Chat Input View" in the left sidebar. You should be able to link it to the existing outlet there. |
@steve228uk, override open class var nib: UINib? {
return UINib(nibName: "CustomNib",
bundle: nil)
} For the sake of testing, I am testing it without any other UI elements right now - specifically, all I did to make this current custom NIB is take your existing Here is a screenshot of said Custom NIB: If it helps, here is the error output:
The error leads me to believe the problem is related to the project not recognizing my NIB or that something further needs be done to link my NIB with the rest of the project. Once again, I really appreciate you taking the time to go through this, it means a lot. Please let me know if there is anything else I can provide to make it easier. Just to clarify once again, all I want to do is add a custom button beside the Send button. |
@steve228uk not sure what do you mean by : can you provide example code for this ? |
Ok got it! Succesfully wired them up... but I cant do :
|
have any luck with the custom Input View ? @svmadiraju |
When I try to subclass I tried subclassing |
@svmadiraju @gersonjanhuel @JStrawn I do realise that this thread has been dead for a while but I'll still chip in. These issues are due to the nib, textView and sendButton properties being public access level. Public class members can only be overridden by subclasses defined in the module they are defined in, therefore the access level needs to be changed to open for subclassed MSGInputView's to work. I've submitted a PR #24 for this change and it should hopefully be merged soon 👍 |
@steve228uk Pretty sure this can be closed now since you added the |
Hi @steve228uk,
Amazing framework! A small question from someone new to iOS dev. I wanted to use MSGMessageBody with custom content (neither text, emoji, image, nor video) but am unsure as to what should be modified to implement this. For instance, I want to have a message bubble with a clickable UIButton inside it. Do you think you could help point me towards what/where I should modify to add such custom message formats?
The text was updated successfully, but these errors were encountered: