Azure / azure-mobile-services-cordova

Apache License 2.0
23 stars 25 forks source link

Create wns toast support for Master branch #15

Closed xqiu closed 8 years ago

xqiu commented 8 years ago

To use this new MobileServices.Web.js file:

From the app side in Cordova:

if (client) { // Register for notifications. client.push.wns.registerNative(wnsRegId, $scope.getTags()).done(function () { }, function (err) {

}); } This is the code I use on the server side.

//insert should use Script/Admin authentication admin, and we use master key for the server. //read is to use application key... This will ensure that if application key is disclosed, it will not be able to insert to our table.

function insert(item, user, request) {

// Define a simple payload for a GCM notification. var payload = { "message": item.title };

// Define a payload for the Windows Store toast notification. var payloadwns = '<?xml version="1.0" encoding="utf-8"?>' + ' ' + item.title + '';

request.execute({ success: function () { // If the insert succeeds, send a notification. // Send to all template registrations push.send(item.tag, payload, { success: function (pushResponse) { console.log("Sent push:", pushResponse, payload);

// send a notification for windows (a native registration). push.wns.send(item.tag, payloadwns, 'wns/toast', { success: function (pushResponse) { console.log("Sent push wns:", pushResponse); request.respond(); }, error: function (pushResponse) { console.log("Error Sending push wns:", pushResponse); request.respond(500, { error: pushResponse }); } }); }, error: function (pushResponse) { console.log("Error Sending push:", pushResponse); } }); }, error: function (err) { console.log("request.execute error", err) request.respond(); } }); }

azurecla commented 8 years ago

Hi @xqiu, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution! In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.azure.com.

TTYL, AZPRBOT;

azurecla commented 8 years ago

@xqiu, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.
Thanks, AZPRBOT;

candidodmv commented 8 years ago

+1

xqiu commented 8 years ago

wierd error. My client file looks right, but pushed version looks wrong... So I get it fixed.

phvannor commented 8 years ago

I know its a little awkward, but the source for the compiled JS file is in the main services repo, the changes to push really need to go on to the file below instead.

https://github.com/Azure/azure-mobile-services/blob/master/sdk/Javascript/src/Push/Push.Web.js

We'd then run the build process from there & drop off the new copy of the file here for consumption as a cordova plugin.

GaryMcAllister commented 8 years ago

This has an error in the template registration.

Needs to include the additional lines below the header declaration otherwise the result is a Native registration not a template registration.

registration.templateName = name; registration.templateBody = templateAsString;

atsats commented 8 years ago

When will this change be committed?

adrianhall commented 8 years ago

It won't be committed. The change needs to go in the main JS, per the comment by @phvannor - this repository is only for the actual cordova wrapping.

shrishrirang commented 8 years ago

Closing this PR for the reason @adrianhall mentioned.