I've built an iOS app on the Drupal iOS SDK. That said, I want my logged in user to be able to send a message to another Drupal user. Right now, I'm successfully pulling received Private Messages from my services endpoint - but does anyone know how I would go about successfully posting a message to a specific user id? Are there any tutorials out there for this?
-
Are you using this SDK then => kylebrowning.github.io/drupal-ios-sdk? How is Private Messages implemented/configured on the Drupal side?– Stefanos PetrakisCommented Mar 24, 2016 at 19:17
-
@StefanosPetrakis I am, yes! Right now I've turned the Message type into a services view that displays Private Messages, and I'm pulling the received messages to the app that way. I'm just not sure how I should go about posting a new message to a specific UID... e.g. post a message to uid 42 so that it's displayed in their inbox.– BrittanyCommented Mar 24, 2016 at 21:11
-
So, this is the drupal.org/project/message module you are using?– Stefanos PetrakisCommented Mar 24, 2016 at 21:15
-
@StefanosPetrakis Correct!– BrittanyCommented Mar 24, 2016 at 21:22
-
Reading the docs quickly, I don't see a method for creating Entities (that would be a Message). You can create Nodes, Comments and Users, but not Entities. You can probably work around this situation inside Drupal, but you would need to leave the Message module aside. Would that be an option?– Stefanos PetrakisCommented Mar 24, 2016 at 21:48
|
Show 1 more comment
1 Answer
here is a rough sketch of how you could go about this:
iOS Side: Add a node using DIOSNode's add
Drupal Side:
- Create you own custom content type, e.g. CustomMessage, with a UserID field for collecting the target user of each message. This could be a simple text field, or an Entity Reference field, single or multi-valued.
- Create a Services View that will use a user's UID as a contextual filter, in order to display all messages targeted at a specific user.
-
-
Quick question: I've just implemented this and realized - if I create a text field to grab the targeted user id (e.g. in my app, uid is posted to my created field, 'targetuser'), do I use targetuser as the contextual filter? Uid and targetuser aren't connected? I essentially want my view to say: "Only display messages with this user's user id in the field targetuser" - is this doable? Am I missing something lol?– BrittanyCommented Apr 17, 2016 at 0:55
-
Hey there, do you still need feedback for this? Maybe you could start a new thread, makes more sense, right? Commented Apr 17, 2016 at 7:35
-
Hey Stefanos! YES please :) See: drupal.stackexchange.com/questions/198288/…– BrittanyCommented Apr 17, 2016 at 19:40
-