Azure / azure-mobile-services-cordova

Apache License 2.0
23 stars 25 forks source link

Puth notification without login #28

Closed PeaceDeveloper closed 7 years ago

PeaceDeveloper commented 7 years ago

I need to register my push notifications in a cordova app without a login with a service. Is this possible?

Obs1: My implementation is like explained here: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-cordova-get-started-push/

Obs2: I'm using cordova-plugin-ms-azure-mobile-apps 2.0.0-beta4

Obs3: I receive a error when I try remove the login: "Failed to load resource: the server responded with a status of 405 (Method Not Allowed)"

Obs4: I don't want use login because it is out of scope.

Thank's.

adrianhall commented 7 years ago

Yes, it is possible. You just need to remove the client.login().then(.....) and unwrap the promise that is included.
You will need to tell us which method is causing the error - it's likely that you have not linked the notification hub (which is required and the /push/register endpoint won't be registered if that happens).

PeaceDeveloper commented 7 years ago

My notification hub is configured. The push notifications works fine with client.login().then(.....). But, when I remove client.login().then(.....) and unwrap the promise that is included, then, my cordova app started with an error of push instalation: "Failed to load resource: the server responded with a status of 405 (Method Not Allowed) https://accounts.google.com/o/oauth2/v2/auth?response_type=code...".

I know that there is a recommendation in the paper: "This example shows calling registerForPushNotifications after authentication succeeds, which is recommended when using both push notifications and authentication in your app." But I want to do a workaround.

Thank you very much by your feedback! :+1:

adrianhall commented 7 years ago

Did you turn off authentication on the server as well? The error is coming from google, so it has to be within the path somewhere.

PeaceDeveloper commented 7 years ago

Oh, ok... I turned off authentication, all it's ok now.

Thank you. :+1: