Hitman666 / cordova-ios-voip-push

Register and receive VoIP push notifications in hybrid app projects with Cordova
MIT License
23 stars 28 forks source link

Trouble Setting up #2

Closed dogofpavlov closed 7 years ago

dogofpavlov commented 7 years ago

Hi Hitman666! Thank you so much for creating this library!

Please bare with me as I'm new to PhoneGap/Cordova. I'm trying to setup this plugin with a new hello world blank project and having trouble. I hope it's ok to post here.

I have setup the correct voip certificates on the apple developer website, and I believe I've implemented the code correctly, as I basically just copy/paste what you wrote into a new projects "onDeviceReady" function.

But when I test the app, although it doesnt crash, it seems there is a silent failure and the code no longer executes after I run the "VoIPPushNotifcation.init()"

Here is my code.

`var app = {

initialize: function() {
    this.bindEvents();
},

bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},

onDeviceReady: function() {
    app.receivedEvent('deviceready');

    console.log("why does this show?");
    var push = VoIPPushNotification.init();
    console.log("but not this?");

    push.on('registration', function(data) {
        console.log("registration callback called");
        console.log(data);
    });
    push.on('notification', function(data) {
        console.log("[Ionic] notification callback called");
        console.log(data);
    });
    push.on('error', function(e) {
        console.log(e);
    });

},

receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');

    console.log('Received Event: ' + id);
}

};`

can you think of anything i've done wrong? I know on your instructions you say to install type "cordova plugin add cordova-ios-voip-push", but since I'm using phonegap I type "phonegap plugin add cordova-ios-voip-push" and it seemed to install and update my config.xml

Thank you for your time I really appreciate it!

Also, I know I haven't added the UIBackgroundModes... because I honestly don't know how. Your example shows Xcode and I'm doing this on Windows even though I'm using PhoneGap Build. Is this possible to setup on windows for PhoneGap Build? Where would I add those BackgroundModes for phonegap project?

Hitman666 commented 7 years ago

I'm not following - what do you mean by Windows? As far as I am aware, VoIP push is only available on iOS, so you would only make use of that if you're making an iPhone app. Also, if you wanna set that up - you have to set it up in XCode. Are you referring to Windows Phone app, or?

dogofpavlov commented 7 years ago

Hi sorry to be confusing. All I mean is i'm building this on windows, I don't need a Windows platform target.

I'm building this on Windows by using the Adobe PhoneGap Build Cloud services that compiles my iOS app for me. I'm trying to understand if even though you wrote it for ionic/cordova, if it works for phonegap... particular phonegap build.

dogofpavlov commented 7 years ago

Also, I've recently setup a new project without Phonegap using just Cordova on a Mac. I've setup a new blank project, added the ios platform and your plugin, setup all the apns voip certificates but when I run the code on a device I never have the registration callback that gives me the token fire.

EDIT... I figured it out! I needed to enable push notifications in the project as well. I'm now getting a token

Hitman666 commented 7 years ago

OK, I understand now. So, first things first - I have no experience with PhoneGap build, so can't, unfortunately, help there. Have you opened the XCode project which Cordova creates?

I would suggest going through the README.md file of this project and also make sure to check out the post linked in there about how to set this up on the 'native' side.

Also, am just wondering - does the Ionic example code provided with the project work for you?

Main part which (I think) you're missing is setting it up in XCode after you build the cordova project. But, then again, I could be wrong since I don't have additional info...

dogofpavlov commented 7 years ago

Hi Hitman, I managed to get the token to appear, so now i'm onto actually sending the notification.

One question I do have is... or confirmation... The main point of VoIP for iOS from my understanding is to be able to wake the app up even if it's not running (including when you reboot the device) with a notification Obviously all this functionality is possible by writting the app natively, and your plugin is meant to do the same for Cordova, but does it 100% do the same? Are there any differences in capabilities?

The reason I ask is because I noticed there exist plugins like https://github.com/katzer/cordova-plugin-background-mode which allow for background execution... does your plugin handle all that or will I need to also implement this?

Hitman666 commented 7 years ago

Yep, I'm confirming your doubts. It wakes the app up even when killed. No differences in capabilities. You can look at my tutorial for how to do this in 'pure' native and compare what plugin does, you'll see it's same.

dogofpavlov commented 7 years ago

hi Hitman666, I was able to successfully setup voip notifications and verified receiving them when the app is killed. Thank you very much for your help

Hitman666 commented 7 years ago

👍 glad I helped

AleksandarTokarev commented 3 years ago

@dogofpavlov For me when app is in background or killed, i am not getting notifications with the simplepush.php script. How did you manage to do that?

dogofpavlov commented 3 years ago

I stopped using this plugin and used https://github.com/phonegap/phonegap-plugin-push as it added voip