Email to mail group - Outlook Mail API - android

I need to send via email a pin from an android app to a mail group using Outlook Mail REST API.
How can I achieve this? I can't find anything about groups on the documentation.
I want to avoid to store the admin users in a static config file and POST a request to "https://outlook.office.com/api/v2.0/me/sendmail" with a JSON content like:
{
"Message": {
"Subject": "ADMIN PIN FOR ANDROID APP",
"Body": {
"ContentType": "Text",
"Content": "The secret pin is: 12345"
},
"ToRecipients": [ // ( list generated from config file )
{
"EmailAddress": {
"Address": "user1#company.com"
}
},
{
"EmailAddress": {
"Address": "user2#company.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
},
"SaveToSentItems": "false"
}
Thanks

When you create an email group , you will have a email address target to this group(you could find the address in the property of the group) . With the address, you could call Outlook Mail REST API to send your message :
Create and send messages via Outlook Mail REST API
In addition, the group only accepts messages from people in its organization or on its allowed senders list. If you cannot send the email , you could ask the owner of the group to grant you permission to send to it, and then try again .

Related

Capacitor doesn't recive android specific push-notifications

I try to implement push-notifications to my Ionic4-Capacitor-App.
In the app I have this code:
PushNotifications.register();
PushNotifications.createChannel({ id: '1', description: '2019', importance: 2, name: '2019'});
PushNotifications.addListener('pushNotificationReceived', (notification) => {
console.debug(JSON.stringify(notification));
});
With POSTMAN I try to send the following message:
{
"to": "<User-Token>",
"notification": {
"title": "Default Title",
"body": "Default Body"
},
"android": {
"notification": {
"title": "Android Title",
"body": "Android Title",
"channel_id": "1"
}
}
}
Here is the documentation I used.
The notification I recive has "Default Title" as a title and "Default Body" as a body.
I expected it to have "Android Title" and "Android Body". Additionally, the notification is not pushed to channel 1, but to Miscellaneous.
When I leave out the "root" notification part, no notification is displayed at all.
For everyone who faces the same problem:
Here are the configuration steps I made to send firebase cloud messages via Postman.
Google-Cloud Configuration:
Go To: https://console.cloud.google.com/apis/credentials/consent
Add getpostman.com to the authorized domains
Go To: https://console.cloud.google.com/apis/credentials
Add a new OAuth-Client-ID
Select Webapplication and give it a name.
Set authorized redirect-URL to https://www.getpostman.com/oauth2/callback and save.
Download Json for this account
POSTMAN Configuration:
Set Request-Type to POST
Enter the url: https://fcm.googleapis.com/v1/projects/{your-firebase-project-name}/messages:send
Go to Authorization, select type OAuth 2.0 and click "Get New Access Token"
Grant-Type Authorization Code
Callback URL: https://www.getpostman.com/oauth2/callback
Auth URL: [auth_uri from the json File]
Access Token URL: [token_uri from the json File]
Client ID: [client_id from the json File]
Client Secret: [client_secret from the json File]
Scope: https://www.googleapis.com/auth/firebase.messaging
State: [empty]
Client Authentication: Send as Basic Auth header
When you have done these steps, you should be able to Send messages as described in this documentation: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send

Creating Notifications onesignal not language

I'm adding the push in an application already published, and I just wanted to change how to send the push without having to send a new update to the application.
Today by amazon we send like this:
{"GCM": "{ "data": { "message": "teste" } }"}
And by your system send thus:
{"GCM": "{ "data": { "message": {en:"teste"} } }"}
Is it possible to send a json in this way?
{"GCM": "{ "data": { "message": "teste" } }"}
Due to actual limitations of OneSignal, the default language is always English ('en').
You can check more details in its documentation here: https://documentation.onesignal.com/docs/language-localization

FCM returning response for single registration id when targeted for multiple registration_ids

I am writing app server side of FCM implementation where it will send a particular message to Multiple devices.
I am using registration_ids as key and JsonArray with multiple recipients, however the response returned is showing only for one recipient as follows
{"multicast_id":7185150746202793615,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
I am not sure whether to set any property in firebase console to enable multiple registration ids acceptance.
Following is the request json :
{
"registration_ids":[
[
"eU6HKx7QRMc:APA91bEIoJtHmTFz_MzUgbMkoZvwdlXzrMDbCB1via_fV16MRF_Xc0C0KkkVA1diR8QgzRdQtkCy-6JDd5it_NSaiIbIlBDDi0g2GFkmrE4ESMi43dBODBePQrzFLqiKeDmX26DkXB8i",
"FERTeU6HKx7QRMc:APA91bEIoJtHmTFz_MzUgbMkoZvwdlXzrMDbCB1via_fV16MRF_Xc0C0KkkVA1diR8QgzRdQtkCy-6JDd5it_NSaiIbIlBDDi0g2GFkmrE4ESMi43dBODBePQrzFLqiKeDmX26DkXB8i"
]
],
"notification":{
"title":"Hello FCM",
"text":"Notification details"
},
"time_to_live":3600,
"priority":"HIGH"
}
And the response for this request is
{
"multicast_id":7697036511101523125,
"success":0,
"failure":1,
"canonical_ids":0,
"results":[
{
"error":"InvalidRegistration"
}
]
}
The Problem was with this Json formation for request. It has to be
{
"registration_ids"[ "eU6HKx7QRMc:APA91bEIoJtHmTFz_MzUgbMkoZvwdlXzrMDbCB1via_fV16MRF_Xc0C0KkkVA1diR8QgzRdQtkCy-6JDd5it_NSaiIbIlBDDi0g2GFkmrE4ESMi43dBODBePQrzFLqiKeDmX26DkXB8i",
"FERTeU6HKx7QRMc:APA91bEIoJtHmTFz_MzUgbMkoZvwdlXzrMDbCB1via_fV16MRF_Xc0C0KkkVA1diR8QgzRdQtkCy-6JDd5it_NSaiIbIlBDDi0g2GFkmrE4ESMi43dBODBePQrzFLqiKeDmX26DkXB8i" ],
"notification":{
"title":"Hello FCM",
"text":"Notification details"
},
"time_to_live":3600,
"priority":"HIGH"
}
The extra square brackets ([ ]) is causing the issue.

GCM push notification message outside data dictionary

Is there a way to retrieve the key "message" on the device when sending notification to GCM.
{ "collapse_key" : "score",
"data" : { "k1" : "v1" },
"message" : "Hello World!",
"registration_ids" : [ "DEVICE_REGISTRATION_ID_GOES_HERE" ]
}
From the intent.getExtras(), I'm able to receive the following keys "collapse_key", "from", "k1" and their corresponding values as well. However I do not get key "message". If I do not add anything in the "data" dictionary, I still get push notification without "k1" (as expected).
Push to GCM does not result in errors. Does GCM drop keys not mentioned in "data" dictionary?
Yes the way you have it won't work. Anything you want to add, make it part of the data object:
{
"collapse_key": "score",
"data": {
"k1": "v1",
"message": "Hello World!"
},
"registration_ids": [
"DEVICE_REGISTRATION_ID_GOES_HERE"
]
}

Is there a way to add "hidden" data to a GCM (android push) notification?

Is there a way to somehow add some data to the Android push notification by the server side?
So I can parse the added data in my app and do some actions related to it, like an Id or something like that.
Of course it must be "hidden" so the simple message is not the way I want it.
Of course there is. Every piece of data you put in the message payload can be "hidden". As the developer of an Android app, it's your decision which parts of the payload are displayed to the user and which are not.
In the server side you decide which data you wish to put in the payload of the GCM message (inside the data dictionary), and you decide what to do with it in the application.
{ "time_to_live": 108,
"data": {
"message": "you can display this message",
"id": "123456",
"some-hidden-field": "some-hidden-value"
},
"registration_ids":["4", "8", "15", "16", "23", "42"]
}

Categories

Resources