Google Cloud Messaging single request - java

I've been searching over the web but I can't seem to find some straight answer.
I've got an application developed and now I need to add it notifications. My issue is that I need each device to be unique and send each one of them a different notification. (I don't mean ONE UNIQUE notification) but I mean to send some users a notification and others don't.
How can this be done?

As a part of the GCM infrastructure, you will need to have your own web application that will allow individual instances of your app to register. When this happens, your Android application will pass to the web application a registration ID along with any additional information that you can use to identify the device. Once you have this information stored, you can pick and choose which device should receive your notification.
See: Architectural Overview section in the http://developer.android.com/google/gcm/gcm.html

Related

How to send a chat message to microsoft teams user from an external system upon event?

I need help with Microsoft teams integration. I have an system from which I want to send chat message to a particular user in MS teams upon an event in my system. How do I go about implementing this. The teams graph api documentation is not looking clear to me. Like it has body but no head and tail. I'm confused on where to start for this. I understand I need to use Graph API's create/send chat api to send messages but it says I need to configure a delegate user for this? How do I send messages on behalf of a external system? Can I can use Teams Java sdk based application? Or I need to create a bot? But I think it's for one-2-one conversation is it? I only want to send a one way message from external system to user. Someone with experience in this pls help me on a good approach for this.
All I want is to send chat message from external system to a user in teams.
You cannot use Graph API in this scenario if you want it on behalf of External system. The API is only available when you are having delegated permission.
Other option would be to create a Notification only bot. In this case please keep in mind that the bot needs to be installed in Teams of user you want to send notification. You can use this graph API to install bot in user's Teams- Install app for User.
Once it is installed you need to have user's Conversation.Id and ServiceUrl (maybe store it in database for all users). When you are done with everything you can send Proactive messages.

Sending Teams chat message to person/channel from java service

I need to send a Teams message to user/channel from the java service. These are notifications about events that happen in the application (e.g. when someone sells a product, they should receive a message on the teams that the product has been sold). I have already configured Microsoft Graph API for my application in Azure but as far as I know it is not possible to send message directly to users using "Application" permissions. (DOCS)
Is it any walk around for this restriction? Can I use a newly created account specifically for my purposes to authorize from the Java service in graph API and then sending messages to users?
I also found information about bots and sending proactive notifications to users. Is it possible to use it in my case as a proxy between java app and Teams user?
If I have multiple customers from multiple Microsoft organizations and I want to provide them my bot with proactive notification feature How should I deploy it? Does each client have to provide me an access to the Microsoft AD with application permissions and add my bot to his Bot Service? Or it is possible to deploy the bot only in my environment and make it available to my clients somehow?
What you're trying to do is called proactive messaging and you can read about it here: https://learn.microsoft.com/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages
You can deploy your bot wherever you like so long as you make sure the Teams app is published. You can make your bot available to everyone by publishing to the Teams app store, also called AppSource: https://learn.microsoft.com/microsoftteams/platform/concepts/deploy-and-publish/appsource/publish
If you don't want the app to be available to everyone, there may be a way to publish it to individual app catalogs: https://learn.microsoft.com/MicrosoftTeams/manage-apps

Send requests to Google Assistant from Java

We have developed a Google Action with Dialogflow that responds to personalized requests from users and performs some tasks that require a certain amount of time, usually several minutes.
Our goal is to announce the result of the tasks using the "Broadcast" feature of Google Assistant, but we can't find a way to send the command to Google Assistant.
Our agent receives the user's request and launches a Java application that executes the task, so it is the Java application that must communicate with Google Assistant when the process is finished.
From the Java application we can communicate with the agent using Dialogflow RPC API, but not with Google Assistant.
Is there any way to send the request to Google Assistant from the Java app? or... since we can communicate with our Google Action Agent... how could we send the request through the agent?
In other words, could the agent communicate with google assistant to use any of its features, for example, "Broadcast ..."?
We have checked Google Assistant SDK as alternative, but we are confused about it.
Please, excuse me for my bad English.
Any help would be appreciated. Thanks!
The "Broadcast" feature is not available to user-developed Actions, and probably not a good scheme to use in any event - if users will need to wait for a while for an answer, they probably don't want the answer suddenly announced when they're not expecting it.
Actions are typically meant to be conversational, rather than taking a while to reply with the answer, which is why there is a 5 second limit on how long the fulfillment has to do processing. If you do need to take a while, you have a few options available to you:
First is that you can use some other method outside of the Assistant to deliver the answer - possibly using something like Firebase Cloud Messaging or sending email to the user.
Similarly, you might be able to use notifications. In this scenario, your Java program would send a notification through the Assistant to the user when the information is available and store the result. The user can then activate the notification to continue the conversation and get the result. This has the advantage that the answer isn't just blurted out, possibly when the user isn't ready for it, but does have a downside that speakers don't (yet) support notifications.
You can also look into using a Media Response to set up a way for you to poll for new messages periodically. Under this scheme, you would fire off the Java program which would get the result and then store this in a way your fulfillment server can access. In your reply to the user saying you're working on the results, you would include a Media Response for some audio that plays for, say, 15 seconds. When the audio finishes, your Action will be called again and you can check to see if the result is available. If so, you send the result and continue or end the conversation. Otherwise, just send a Media Response.

How to add the data to Google Analytis by using java (programmatically)

At the current moment, I am trying to understand how to add any data to GA. I read the data from my GA account using Core Reporting API and Managment API without any problems. But now I want to add the data (the number of phone calls) to GA account programmatically. Somebody can explain me step by step - how can I do this?
The Measurement Protocol is how we send data to Google Analytics. The JavaScript snippet that we use in our websites also uses the Measurement protocol as do the SDK's for Android and IOS. Unfortunately there is no (official) SDKs for the other languages like Java for instance.
That being said you can technically code it yourself in any language that can handle a HTTP get or a HTTP post. I have personally done it for C#.
POST /collect HTTP/1.1
Host: www.google-analytics.com
payload_data
The following parameters are required for each payload:
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=555 // Anonymous Client ID.
&t= // Hit Type.
A few tips to get you started.
Check out validating hits this is very useful in the beginning for debugging your requests.
some of the parameters are only valid for certain hit types. Make sure you check the documentation.
Cid is just a string it can be anything most people send a Guid its basically used by the server to identify a unique session.
if you are doing this for an application google analytics account remember to send screenview not pageview the same goes for web application.
check the realtime report on google analytics to see if your hits are getting recorded.
Update for question in comment:
I recommend while you are getting the idea of this you start with just using HTTP GET in a web browser. Its easer to test your requests against debug that way. For example put this in a browser.
https://google-analytics.com/debug/collect?v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA
DP is document path and I am not sure why it is requiring that you send that.
ScreenView hit type VS PageView hit type.
There are two types of Google Analytics accounts ones for applications like android applications or sometimes web applications, and web sites. Application Google analytics accounts are meant to be used with ScreenView hit (the user checks a screen in the application) type and web accounts use PageViews (the user views a webpage). If you send a Pageview to an application Google Analytics account it will accept the hit but there will be no way for you to see the data. If you send a ScreenView to a web Google Analytics account it will again accept the data but you wont see it.

What is registration ID in Android and how does it creates internally?

I'm new to Android and I don't understand some concepts.What is registration ID used in Google Cloud Messaging?How does it creates internally - it is unique device id as Apple device token or something else?How does it differs from application id? It is may be a stupid question but I really don't understand the concepts.
Is the temporally ID that allows to GCM services identify your device-application, so trough your server you can send messages to GCM and this will redirect it to your device. More info here
In advance i copy some text:
An ID issued by the GCM servers to the Android application that allows it to receive messages. Once the Android application has the registration ID, it sends it to the 3rd-party application server, which uses it to identify each device that has registered to receive messages for a given Android application. In other words, a registration ID is tied to a particular Android application running on a particular device.
It's documented quite fine there: http://developer.android.com/google/gcm/gs.html
For sender ID:
Open the Google APIs Console page. If you haven't created an API
project yet, this page will prompt you to do so:
Note: If you already have existing projects, the first page you see
will be the Dashboard page. From there you can create a new project by
opening the project drop-down menu (upper left corner) and choosing
Other projects > Create. Click Create project. Your browser URL will
change to something like:
https://code.google.com/apis/console/#project:4815162342
Take note of the value after #project: (4815162342 in this example). This is your project number, and it will be used later on as the GCM
sender ID.
As for ID returned after GCM registration - how it is created is not really important, but it's unique ID per your device + the Google account active on the device.

Categories

Resources