-1

This is my code in index.js:

$.ajax({
    type: 'GET',
    data: {registrationdata: registrationDataJson},
    async: false,
    url: 'https://example.com/push_reg',
    success: function(data){
        alert("Your device has been successfully registered for push notifications with device id of: " + data);
    },
    error: function(){
        alert('There was an error registering your device');
    }
});

I have tried it with both async on and async off. I do not get any alert from either success or error. I put a log line first thing where /push_reg routes. If I hit it in a desktop browser it logs but not from the app. I have alert(registrationDataJson); right before this code block (registrationDataJson is a stringified JSON) so I know the data is good. I have alert('after'); directly after this code block that I never hit so I know that it never gets past this block.

lola_the_coding_girl
  • 843
  • 2
  • 10
  • 22

2 Answers2

0

You might want to elaborate and indicate what error messages code / errors you are seeing. Check your config for setting, etc.

SScotti
  • 2,158
  • 4
  • 23
  • 41
0

Please check your config.xml file and make sure that you have these:

<plugin name="cordova-plugin-whitelist" source="npm" spec="1.1.0" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />

<preference name="permissions" value="none"/>
Sarantis Tofas
  • 5,097
  • 1
  • 23
  • 36