-
Notifications
You must be signed in to change notification settings - Fork 21
Sending messages
With Mobile Messaging library you can send messages to arbitrary destinations from mobile device. These messages are also known as Mobile Originated (MO) messages.
MO messages sent from users' smartphone can be forwarded by our system to your own server. To activate the service please follow the configuration setup and action setup.
Once your server receives an MO message, it’s up to its logic to identify the message recipient (destination identifier) and what to do with data received from mobile devices. Destination identifier might be any string you choose to define as the wanted destination of your MO message.
NOTE: Please, follow the instructions linked above for configuring MO forward action. Without this configuration you won't be able to receive MO messages on your server.
Following example code shows how you can send MO message using Mobile Messaging library API:
//Swift
let customPayload = ["order_name": "pizza_capriciossa",
"rushed_delivery": true,
"coupon_number": 44869320]
let moMessage = MM_MOMessage(destination: <# destination identifier #>,
text: <# message text you want to send #>,
customPayload: customPayload)
MobileMessaging.sendMessages([moMessage]) { (messages, error) in
// handle the error if one occurs
if let messages = messages {
for message in messages {
if message.status == MM_MOMessageStatus.SentSuccessfully {
//message sent successfully
} else {
//message sent with failure
}
}
}
}
//Objective-C
NSDictionary *customPayload = @{@"order_name": @"pizza_capriciossa",
@"rushed_delivery": @YES,
@"coupon_number": @44869320};
MM_MOMessage *moMessage = [[MM_MOMessage alloc] initWithDestination: <# destination identifier #>
text: <# message text you want to send #>
customPayload: customPayload];
[MobileMessaging sendMessages:@[moMessage] completion:^(NSArray<MM_MOMessage *> * messages, NSError * error) {
// handle the error if one occurs
for (MM_MOMessage *moMessage in messages) {
if (moMessage.status == MM_MOMessageSentStatusSentSuccessfully) {
//message sent successfully
} else {
//message sent with failure
}
}
}];
Mobile Messaging SDK supports following notifications MMNotificationMessagesWillSend
and MMNotificationMessagesDidSend
that posted through the NSNotificationCenter
.
More information about these and other notifications here: Library events.
After you've configured desired MO actions your server is able to receive sent inbound messages.
An error "Push MO route is not available for your account. Please contact your account manager." (HTTP status code 403) may be received in response to attempt to send a message from mobile device. Contact your account manager to address the issue.
If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
Geofencing serviceDEPRECATED- Privacy settings
- In-app chat
- WebRTC Calls and UI