There is a way to send custom data in push notification in Windows Phone? - windows-phone-8

I know that are Raw Notifications on WNS but the whole content of the notification is showed in the notification. I wanted to do like APNS and GCM does. A custom properties in the json payload that it's delivered to the app but its not showed to the user. There is a way to do that in WNS?

You can send parameters in launch attribute, it can be similar to url. For example, for toast notifications:
<toast launch="?param1=sample&param2=sample2">
</toast>
and parse it in the application. Value from launch attribute can be retrieved in OnLaunched handler. HERE is an article about handling activation from a toast notification (from MSDN).
Note: you can put into launch any other format you want. I suggested uri-based parameter because it is easy to parse using WwwFormUrlDecoder, which is mentioned HERE.

Related

Sending CURL/MQTT from chrome URL bar

Basically I have a script on a server that runs on a MQTT/CURL signal. Once either the MQTT or CURL gets called It starts/runs the script on the server and from there transfer the data to other machines. Why I want this to be run from Chrome (or any other browser) is because I would like to use a QR scanner to scan a QR code which holds the URL(mqtt or curl) and that this then gets run from the internal browser on the device. I know that there are apps and extensions for this, but I really need to get it as "thin client" as possible due to the large amount of devices that needs to be able to send the signal. Downloading an app for each device would defeat the purpose.
So my question really is if this is possible? Can Chrome send mqtt/curl from the url/address bar. I can't seem to find any information on this (maybe because it doesn't work? :D) HTTP post wont do unfortunately.
EDIT: If it doesn't work I have an idea to curl post from the console, but then my question is how would an url that opens console and inserts certain information look like? In other words I want an URL to include in my QR picture that opens Chrome (because it's a link) opens console and writes data like 101011101 (I can do the ENTER manually)
Kind regards,
First, no Chrome can not in a single externally triggered action send a MQTT message. *
Curl is just a command line HTTP client it can send any HTTP request possible by the spec, so without LOT more detail about what exactly you are using it for the next part of this answer has to be a bit of a guess.
If you scan a QR code containing a HTTP URL then this will most likely be passed to the built in browser on the device (or a WebView in the barcode scanner application). This URL will opened using a HTTP GET request (you can not change the HTTP verb, it will always be a GET).
You can encode variables into the URLs query string by appending them to the end of the URL e.g.
http://www.example.com?foo=bar
Would send a variable named foo with a value of bar and as long as you have room in the data you store in the QR code you can add as many of these as you want.
* Chrome could be passed a URL to a page that loads the Paho Javascript MQTT library that then sends a message via MQTT over Websockets if the broker supports it, but if you are going to do that you might as well have what ever HTTP server that you load the page from send the message.

Sending a message from FCM Console not working for Web Tokens

I am implementing Web Push Notification in an application and I have successfully registered the client app with GCM. I have the subscription object that contains the endpoint that looks like this.
"https://android.googleapis.com/gcm/send/dV4lSfI5J6Q:APA91bEU28F9YG5qNr3xSjvYlH2Mh1GPgiqMaRcjandHbpfqnVyAeZxqoE31OXYq4yzW2_vrkn74YHdgsITZP_6SELO8-xHf1hylquJefJdY85-Xx9AWTAPP9H6kfq7CKp23dsoQHbH
I read and found out that we need to use a third party library like web-push to send push using this endpoint to the clients because the payload needs to be encrypted according to spec. My objective is to send notifications to all my users, web + mobile, at once, using Firebase Console's Notification feature.
Is there a way to send push to web clients using Firebase console or to convert the GCM endpoint to an FCM token?
Update: If I try to use Firebase console to send push the token generated above, I get the following error.
As per testing this out, for some reason, registration tokens for Web are not working or allowed in the Firebase Console. Only tokens for Android and iOS do:
The request could still proceed where the console would show that it is sent/complete, but there wouldn't be any messages received.

push notification azure to FCM topics

I want to push notification messages from azure notification hub to the FCM using topics.
Example: I want to send a message to the FCM from notification hub. but this message will be directed to topics. When using postman for example, I just have to send this json:
{
"to" : "/topics/scalability",
"notification":{"body":"topics message sent"}
}
to https://fcm.googleapis.com/fcm/send (while providing the FCM key ofcourse).
By doing this, I am able to receive the notification on a chrome app I put in place (the app is just the same as you can find here
Now my problem is that when I send this same message on Notification hub (Azure), I don't receive it on my web app. My understanding is that the Notification Hub does not push the message (json) in its simple format, but why is that ?
Since I successfully pushed the message to FCM, isn't the FCM supposed to interpret the
"to" : "/topics/scalability
part ?
I found a workaround. I send notifications using the simple version of the Notification hub method:
// Send the message to FCM NotificationOutcome outCome = await this.hubClient.SendGcmNativeNotificationAsync(payload).
I then receive all the messages from my chrome app
Azure Notification Hub supports registering tags with individual device. And you can use tag expressions to target specific sets of devices, or more specifically registrations, when sending a push notification through Notification Hubs. For targeting, you should use tag expression instead FCM ‘to’ property. Please see below article for more details on routing/expressions.
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message
I know this is an old question but I also was confused by this when starting my first Topics-based notification hub app, so hope this saves someone, somewhere some time. What SHOULD, in my opinion, be explicitly stated somewhere in the azure NH documentation, is that using the hub with PNS such as Firebase will OVERRIDE any PNS specific Topics functionality. My understanding is that if you decide to go the Hub route, you ditch Firebase Topics etc and work exclusively with Hub Tags.
If you think about it, it actually makes a lot of sense as it means the Hub is dealing with Topic filtering rather than firing off all messages and making the PNS systems do their individual things.
So in short, if you go the NH route, you cant use PNS topics, I found the two don't play nicely together.

Facebook login broken, oauth response serialization changed from CGI parameters to JSON

Today the Facebook oauth login to my website broke. I fired up the debugger and found that parsing the access token was failing. This appears to be because Facebook changed the format of the oauth response. It used to be CGI parameters:
access_token=EAAFO...cBUZD&token_type=bearer&expires_in=5183996
But all of a sudden it appears to be coming over as JSON:
{"access_token":"EAAFO...cBUZD","token_type":"bearer","expires_in":5183996}
The fix in my code looks pretty simple. I just need to change the parser from a CGI parser to a JSON parser and get the same variable that I'm interested in: access_token.
My question is about versioning of this. I don't like it when my site breaks.
Why did Facebook change this? Is this change documented? Is there some sort of versioning on Oauth that I should be using to prevent breakages like this? How do I get notified of future changes to Oauth by Facebook?
The Facebook API upgrade tool does not list any changes that I need to my app for the latest version of the API. In any case, none of the URLs that I'm using for Oauth appear to have a version number embedded in them:
https://www.facebook.com/dialog/oauth
https://graph.facebook.com/oauth/access_token
As WizKid states, it was announced in Facebook Developers Changelog two years ago under the title "[Oauth Access Token] Format". Facebook does have a tool to try to find things that will break, because of API changes, but it didn't alert this one.
You can put API version numbers into Oauth URLs for Facebook. With version numbers, the flow for Facebook login is:
Redirect the user to https://www.facebook.com/v2.9/dialog/oauth with a bunch of required parameters such as your client id, the list of permissions you are requesting, and a return URL.
Facebook lets the user log in, asks them to accept the permissions you requested, and then redirects them back to your site with a "code" parameter
Server-side you contact https://graph.facebook.com/v2.9/oauth/access_token with that code (and some other stuff) as parameters. Facebook responds with a token
Server-side you contact https:///graph.facebook.com/v2.9/me with that token to request information about the user
This is the process that is pretty much documented here: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

Access data from an actual API service in protractor tests

I am writing end-to-end tests using Protractor for an Angular application. The application uses an API service to retrieve data from the back-end and this data is then used to populate pages in the Angular application.
I would like to utilize this API to get data to use in my jasmine tests, the tests will confirm that the back-end data is correctly and completely populated on applicable pages in the UI. I definitely DO NOT want to mock the server, I want to hit the actual server and work with the actual data from the JSON response.
My question is 2 sided; how to call the API service from my protractor tests and secondly, how to retrieve data from the JSON response from this API.
Any (detailed) information, examples you can provide as to how this can be done would be appreciated
Thanks in advance.
Protractor is used to test the ui of an application. What it does is click buttons and enter text in text boxes and wait for responses. For example if I have a login form and want to test the scenario when a user enters an email address wrong and an error message pops up. Protractor would navigate to the email field, enter an incorrect email address and then find the element that contains the error and verify the error showed up.
So as long as you have an environment setup that has a ui connected to an API service, the API service will be called as normal. Protractor will click buttons and if a button click triggers a call to the API service it will go straight to that service.
As for the JSON response access, this is probably not a good use for protractor. Protractor is used to click events and wait for responses. So if you are displaying that JSON response in some form or way protractor could verify it is displayed. For example, if you are displaying some data from the server in a table on a button click, you could have protractor click that button and verify the table has the correct values. But you would not want to verify the JSON object is as expected. That would be unit-tests on the API itself.
Hope this helps.
We have two options
Make a request by require(...) and using a request library.
This allows you to make direct HTTP Service calls, as discussed in this Stack Overflow post
Use some data from a .json file by require(...) it directly:
https://github.com/angular/protractor/issues/978#issuecomment-47250364