PeterStaev / nativescript-azure-mobile-apps

:cloud: NativeScript plugin for working with Microsoft Azure Mobile Apps services
Apache License 2.0
30 stars 10 forks source link

Error 404 when i am passing my url #24

Closed skhye05 closed 6 years ago

skhye05 commented 6 years ago

@PeterStaev Thank you for this amazing plugin.

I want to use to received push notification from azure notification hub but I am unable to register my token and its return an error code of 404. the URL has been set up and everything do you what could be the issue when one received such error? and why are you passing the URL instead of the DefaultListenAccessSignature?

I am using Nativescript Angular. I am initializing the push notification on my app.component.ts when the app load. here a snippet of the file

  constructor() {
        this._client = new MobileServiceClient('portalUrl');
        this.registerPush();
    }

    ngOnInit(): void {

    }

    public registerPush(): void {
        pushPlugin.register({ senderID: 'sender_id' }}, (token: string) => {

            console.log('Device registered. Access token: ' + token);

            this._client.push.register(token)
                .then(() => console.log("Azure Register OK!"))
                .catch((e) => console.log(e));
        }, function () { });

        pushPlugin.onMessageReceived((stringifiedData: String, fcmNotification: any) => {
               alert('Message received!\n' + notificationBody + '\n' + stringifiedData);
        });
    }
PeterStaev commented 6 years ago

Hi @skhye05 ,

I have never seen a 404 error. Are you sure you are using the correct portal url? This must be the URL of the mobile app in Azure. Note that this plugin does NOT work if used directly with notification hubs. All the notifications hub APIs have been depreciated by MS are are now surpassed by the Mobile Apps Service APIs. So in Azure you must create a Mobile App project and then link your notification hub to it. Then user the URL of the Mobile App.

Hope this helps!

PeterStaev commented 6 years ago

No further response so closing this one for now. In case you still have problems, please provide more details.

Jeremywhiteley commented 6 years ago

I am sorry! Thank you for your help! I will be using it for the Nativescript app.