In our project we use Firebase cloud messaging for push notification and we encountered the problem of duplication of messages. Our process looks as follow:
our client side based on iOS device and we use follow sdk
Xamarin.Firebase.iOS.CloudMessaging 3.1.2
Xamarin.Firebase.iOS.InstanceID 3.2.1
Xamarin.Firebase.iOS.Core 5.1.3
when user login the application request the token
application send this token to server which is subscribe this token to topic
Subscribe user for topic reuqest
POST https://iid.googleapis.com/iid/v1:batchAdd
request body
{
"to" : "/topics/test",
"registration_tokens" : ["..user_registration_token.."]
}
server send periodically notifications to the topics
Send notification for topic subscribers request
POST https://fcm.googleapis.com/v1/projects/our_project_id/messages:send
request body
{
"message":
{
"topic":"test",
"notification":
{
"title":"test-6",
"body":"test-6"
}
}
}
when user logout from application, server perform unsubscribing user token from topics
POST https://iid.googleapis.com/iid/v1:batchRemove
{
"to": "/topics/test",
"registration_tokens" : ["..user_registration_token.."]
}
But, when user login again and request brand new token, device still received push notifications which are sending to the old token, and if we send notifications by the topic such users received duplicate push notifications.
If we try get information for old token from api method
GET https://iid.googleapis.com/iid/info/token.....
we get response
<HTML>
<HEAD>
<TITLE>Internal Server Error</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Internal Server Error</H1>
<H2>Error 500</H2>
</BODY>
</HTML>
try to add ?details=true to your uri.
Be sure to use Authorization key in your header.
Output expected is
{
"error": "No information found about this instance id." }
or
{
"application": "com.chrome.windows",
"subtype": "wp:http://localhost:8089/#xxx-xx-xx-xx-xx-x",
"scope": "*",
"authorizedEntity": "xxxx",
"rel": {
"topics": {
}
}
},
"platform": "BROWSER"
}
Related
I'm trying to connect to google home using OAuth2.0 mechanism. However, hitting with an issue where I'm not able to retrieve success message.
The failing request is - https://oauthintegrations.googleapis.com/v1/token:getForService
with the response payload as redirectState. I know about redirect but what is redirectState? I tried to search a bit over this one, but failed.
Any help would be appreciated.
Note:I have followed all the necessary steps mentioned in doc, I can receive authorisation code, but not able to make token request to desired endpoint.
The docs are https://developers.google.com/actions/identity/oauth2-code-flow and https://developers.google.com/actions/identity/account-linking.
In configuration settings we have Linking type as Oauth -> Authorization Code.
In dialog flow in Integration -> Integration Settings we have checked in for 'Sign in required' for Default Welcome Intent and have the firebase function as
app.intent('Default Welcome Intent', (conv) => {
conv.ask(new SignIn());
});
according to https://developers.google.com/actions/identity/account-linking document and I am currently using API version V2.
After the auth code is received as mentioned it does not call token url, we receive this screen :
Bad response from IdP in Auth Code Exchange & what is redirect_state
The https://gala-demo.appspot.com/app#redirect_state=XXX&state=yyy&service=abc when inspected fails at https://oauthintegrations.googleapis.com/v1/token:getForService as mentioned by #rajesh with status code 400, but when this request is made through postman it return the response. Here is the body and response for the request.
Body :
{
"credential" : {
"redirectState": "XXX"
},
"scopes": [],
"gdiState": "APP_AUTH",
"serviceId": "tapclicks-integration-adac2_dev"
}
RESPONSE :
{
"serviceInfo": {
"authUrl": "https://-domain-/authorization",
"name": "tapclicks dashboard",
"logoUrl": "https://placeholder.com/",
"clientId": "zdqexVMaVvxIMQ7Frjwa",
"tokenUrl": "https://-domian-/token_url",
"privacyPolicyUrl": "https://placeholder.com/",
"tosUrl": "https://placeholder.com/",
"id": "tapclicks-integration-adac2_dev"
},
"completionInfo": {
"appauthInfo": {
"appauthRedirectUrl": "https://-domain-/authorization?response_type=code&client_id=zdqexVMaVvxIMQ7Frjwa&redirect_uri=https://oauth-redirect.googleusercontent.com/r/tapclicks-integration-adac2&scope=gmail&state=yyy",
"appauthRedirectState": "abcxxx"
},
"oauthAuthorizationUrl": "https://-domain-/authorization?response_type=code&client_id=zdqexVMaVvxIMQ7Frjwa&redirect_uri=https://oauth-redirect.googleusercontent.com/r/tapclicks-integration-adac2&scope=gmail&state=yyy"
},
"gdiState": "APP_AUTH",
"header": {}
}
Can you please tell if i might be making any configuration mistake or any other info you need.
Authorization Url : https://kprb95tye7.execute-api.us-east-1.amazonaws.com/authorization/
Token Url : https://9343j46f16.execute-api.us-east-1.amazonaws.com/token_url/
Thanks
I'm writing an application which should send push notifications from the server to android and iOS devices. I try to use FCM for this purpose.
iOS application used APNS so I can obtain apns subscription tokens on server side. Then I try to batch import these tokens, I get back some kind of registration tokens with length of 174 symbols instead of usual 152 used in Firebase.
When I use IID method GET https://iid.googleapis.com/iid/info/{token}, it successfully returns information about given token, but when I try to send message directly using this token by using HTTP v1 API POST https://fcm.googleapis.com/v1/projects/{0}/messages:send method with target field "token":"f5MpeWlqg0E:APA91bHGpRR3_ygt10....CdI3Rtsodf8XMIQNlflF23mQ" and ios specific payload, I get an error:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
},
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "message.token",
"description": "Invalid registration token"
}
]
}
]
}
}
Then, if I try to send same message to the same token again, I get another error:
{
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND",
"details": [
{
"#type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "UNREGISTERED"
}
]
}
}
And IID method returs 404 too, meaning that Firebase removed my token from system.
The question is why do I get "wrong" token from IID that I cannot address and how can I send direct notifications to iOS phones.
Ok, the problem was in iid settings: when I tried to retrieve FCM token from APNS token I set "sandbox" to false, but used sandbox certificate, so the token was invalid.
I am working on Mattermost API.
Currently i am stuck with web socket.
To authenticate with an authentication challenge, first connect the WebSocket and then send the following JSON over the connection
{
"seq": 1,
"action": "authentication_challenge",
"data": {
"token": "mattermosttokengoeshere"
}
}
How can i sent this JSON.
Thanks
In Mattermost 3.5 and later, you can authenticate your WebSocket by connecting and then providing the token in a JSON formatted authentication challenge over the WebSocket.
An example authentication challenge would look like this:
{
"seq": 1,
"action": "authentication_challenge",
"data": {
"token": "mattermosttokengoeshere"
}
}
If the WebSocket authenticates correctly then you will receive a standard ok response looking like this:
{
"status": "OK",
"seq_reply": 1
}
All previous versions of Mattermost before 3.5 will require the token in the cookie. Mattermost 3.5 still supports authenticating through the cookie.
See this forum post for further information: https://forum.mattermost.org/t/how-to-pass-credentials-to-websocket-from-external-domain/2500/2
Im using the new Firebase platform. Am trying to get a push notification sent by my app server and delivered to my iPhone.
I have the setup working where I manually send the message with the Firebase notifications area on the website, but when I try and send the message with a POST to https://fcm.googleapis.com/fcm/send I get no message being delivered to the device.
I'm sending the following (with auth headers)
{ "notification": {
"title": "Portugal vs. Denmark",
"text": "5 to 1"
},
"to" : "<registration token>"
}
I'm getting a 200 response from the POST with the following body:
{
"multicast_id": 5511974093763495964,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1463685441784359%3ad254b53ad254b5"
}
]
}
If I try and send to this device directly through the Firebase website it works, but the above form post doesn't. No idea where to go from here!
On iOS the priority field seems mandatory.
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}
If the API returns you a message_id it means that your message has been correctly accepted and it will eventually be delivered to the device.
On Android, messages are delivered as soon as possible (provided that the device is connected of course).
On Apple devices, IF the application is closed or in background, the notification is sent through Apple infrastructure and can be delayed accordingly with Apple documentation.
To reduce the delay of the prioritymessages sent to Apple device you can use the priority parameter.
More details: https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message
I found the message field to be required, as well as the priority field to deliver a message with a POST.
message is not required (and labeled as optional) in the Firebase Console.
I resolved adding the notification tag in request body without priority.
Here is a recap:
I have a problem sending messages GCM with Xtify.
My device is registered but it doesn't appear in Test Implementation. The app is testing.
I send this message from my server to xtify it is accepted with 202 status code but the message doesn't reach the device.
{"apiKey":"blabla-2c0e-4c90-8845-753ed8ac3d64","appKey":"blabla-e6d0-441f-8b32-c0fc8be4ee5b","xids":["asdsd387242167c695bbac"],"sendAll":false,"content":{"subject":"Oferta","message":"lat=39.50017;lon=-0.43342;dis=50.0;oferta=1;","action":{"type":"NONE","data":"","label":""}}}
Where is the problem? Thank you
202 is a success codes, it means that xtify servers accepted the request but not necessarily deliver it to the device. I recommend following these steps to make sure your app registers with xtify, also make sure that your application in the app manger set to "Development / Testing" so you could be able to see it in the test page.
Push API call example for GCM:
URL: http://api.xtify.com/2.0/push
Content-Type: application/json
HTTP entity body:
{
"apiKey": "xxxxxx-xxxxx-xxxx-xxxxx",
"appKey": "xxxxxx-xxxxx-yyyy-xxxxx",
"xids": ["xxxxxxxxxxxxxxxxxx"],
"sendAll": true,
"content": {
"subject": "Greetings Earthlings",
"message": "Take me to your leader",
"action": {
"type": "DEFAULT"
}
}
}