3

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?

6
  • Are you using this SDK then => kylebrowning.github.io/drupal-ios-sdk? How is Private Messages implemented/configured on the Drupal side? Commented 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.
    – Brittany
    Commented Mar 24, 2016 at 21:11
  • So, this is the drupal.org/project/message module you are using? Commented Mar 24, 2016 at 21:15
  • @StefanosPetrakis Correct!
    – Brittany
    Commented 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? Commented Mar 24, 2016 at 21:48

1 Answer 1

1

here is a rough sketch of how you could go about this:

iOS Side: Add a node using DIOSNode's add

Drupal Side:

  1. 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.
  2. 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.
6
  • Ur welcome, good luck! Commented Mar 24, 2016 at 22:25
  • 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?
    – Brittany
    Commented 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/…
    – Brittany
    Commented Apr 17, 2016 at 19:40
  • Nevermind - I figured it out your way : ) Thanks again!
    – Brittany
    Commented Apr 17, 2016 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.