Help with Installation of Icenium Push Plugin

4 posts, 0 answers
  1. Bruce
    Bruce avatar
    38 posts
    Member since:
    Oct 2009

    Posted 25 Aug 2013 Link to this post

    All,

    I have been trying in vain to get the Push plugin to work on my GeoAPITestApp2 project. I have followed the documentation, and still get no error but my app doesn't get past the pushPlugin = window.plugins.pushNotification line.  My files are located here



    What I have done so far:
    1) Successfully created my adhoc certificate, valid until August 2014

    2) Successfully imported my adhoc certificate into Mist. 

    3) Added the Push Plugin according to the directions from documentation entitled "Enable and Configure Integrated Plugins". This created a Plugins folder named "com.phonegap.plugins.pushPlugin-1.2.2"

    4) Based on the documentation notice "Starting with Icenium 1.7, Icenium maintains integrated plugins as custom Apache Cordova plugins. For more information, see Working with Custom Plugins" I went to that section

    5) I checked the plugin.xml for the asset line and added the include line in my index.html file

    6) I build my app using my adhoc profile.

    7) I download the app.ipa file.

    8) I upload the app.ip file to TestFlight

    9) I load the app.ipa file on my device through TestFlight

    When I run my app, it hangs at the line pushNotification = window.plugins.pushNotification; I am thinking for some reason the js file is not found, but I can't seem to get this right, and I have no errors in my console.

    If anyone can provide some additional instruction or guidance, I'd appreciate it.

    Thanks,
    B
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 28 Aug 2013 Link to this post

    Hi Bruce,

    It might sound trivial but can you check again if some of the following items is not the problem in your case:
    • The application identifier set in Project Properties is exactly the same as configured on the iOS provisioning portal. If you have an ad-hoc mobile provision you do not have to include the bundle prefix (Seed ID) in the identifier.
    • Make sure your firewall is not blocking any of the calls.

    Also it would be good if you try to isolate your problem in a separate application. Just take the code from the blog post and try to make it work with a new App ID and a developer/ad-hoc provision.

    Additionally, you might be interested that our BaaS provider Everlive offers Push Notifications services and significantly eases you in the configuration process, for more info please refer to  Introducing Push Notifications services: Push for hybrid apps made easy.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  3. Bruce
    Bruce avatar
    38 posts
    Member since:
    Oct 2009

    Posted 28 Aug 2013 Link to this post

    Hi Steve,

    Thanks for your reply. I have checked my adhoc provision repeatedly and it is identical in every way to my AppID. I have a sneaking suspicion the issue is with the asset line in the plugin.xml file and the <script src...> line in my index.html. based on my script below, I never get past line 12 below. It doesn't seem to matter which plugin I try either. 

    001.(function (global) {
    002.     
    003.    var mobileSkin = "",
    004.        app = global.app = global.app || {};
    005. 
    006.    var pushNotification;
    007.     
    008.    document.addEventListener("deviceready", function () {
    009.         
    010.        app.application = new kendo.mobile.Application(document.body, { layout: "tabstrip-layout" });
    011.      
    012.        pushNotification = window.plugins.pushNotification;
    013.                 
    014.         
    015.        Login();
    016.        StartWatchingLocation();
    017.                 
    018.    }, false);
    019. 
    020.    app.changeSkin = function (e) {
    021.        if (e.sender.element.text() === "Flat") {
    022.            e.sender.element.text("Native");
    023.            mobileSkin = "flat";
    024.        }
    025.        else {
    026.            e.sender.element.text("Flat");
    027.            mobileSkin = "";
    028.        }
    029. 
    030.        app.application.skin(mobileSkin);
    031.    };
    032.        
    033.    function WatchPositionSuccess(position){
    034. 
    035.        $("#divStatus").prepend("**********************************</br>");
    036.        $("#divStatus").prepend("Updating Position!...</br>");
    037.        $("#divStatus").prepend(position.coords.latitude +"</br>");
    038.        $("#divStatus").prepend(position.coords.longitude +"</br>");
    039.        $("#divStatus").prepend(position.coords.speed +"</br>");
    040.        $("#divStatus").prepend(position.coords.altitude +"</br>");
    041.        $("#divStatus").prepend(position.coords.accuracy +"</br>");
    042.        $("#divStatus").prepend(position.coords.altitudeAccuracy +"</br>");
    043.        $("#divStatus").prepend(position.timestamp +"</br>");
    044. 
    045.        $.support.cors = true;
    046. 
    047.        var request = $.ajax({
    049.            type:'POST',
    050.            dataType:'json',
    051.            contentType:'application/json',
    052.            headers: {
    053.                "Authorization-API":"fd75ec92-9d2f-429b-9057-a2830bef9d93"
    054.            },
    055.            data:JSON.stringify({
    056.//                "user_id": "520aae4a296d1e0b101c3cf5",
    057.                "user_id": '454180c04996bb896a97334f6816a502ed9e813b302add8becb5bf9d137f2c21',
    058.                "latitude": position.coords.latitude,
    059.                "longitude": position.coords.longitude,
    060.                "speed": position.coords.speed,
    061.                "altitude": position.coords.altitude,
    062.                "horizontal_accuracy": position.coords.accuracy,
    063.                "vertical_accuracy": position.coords.altitudeAccuracy
    064.            })
    065.        });
    066.         
    067.        request.done(function (response, textStatus, jqXHR){
    068.            $("#divStatus").prepend("Updating Position returned success!...</br>");
    069.            console.log(JSON.stringify(response));
    070.        });
    071.         
    072.        request.fail(function (jqXHR, textStatus, errorThrown){
    073.            $("#divStatus").prepend('Updating Position returned failure ' + JSON.stringify(textStatus) + ' </br>');
    074.            $("#divStatus").prepend(jqXHR.responseText);
    075.        });
    076.    }
    077.     
    078.    function WatchPositionError(error){
    079.            $("#divStatus").prepend('WatchPosition returned failure ' + JSON.stringify(error) + ' </br>');
    080.    }
    081.     
    082.     
    083.    function SubscribeToPush(token){
    084.        var request = $.ajax({
    086.            type:'POST',
    087.            dataType:'json',
    088.            contentType:'application/json',
    089.            data:JSON.stringify({
    090.                "channel":"BAIRFINDER-DEFAULT",
    091.                "device_token":token
    092.            })
    093.             
    094.        });
    095.         
    096.        request.done(function (response, textStatus, jqXHR){
    097.            $("#divStatus").prepend("Subscribed to ACS Push!...</br>");
    098.            console.log(JSON.stringify(response));
    099.        });
    100.         
    101.        request.fail(function (jqXHR, textStatus, errorThrown){
    102.            $("#divStatus").prepend('Subscription to ACS Push returned failure ' + JSON.stringify(textStatus) + ' </br>');
    103.            $("#divStatus").prepend(jqXHR.responseText);
    104.        });
    105. 
    106.    }
    107.     
    108.    function StartWatchingLocation(){
    109. 
    110.        var watchId = navigator.geolocation.watchPosition(
    111.            WatchPositionSuccess,
    112.            WatchPositionError,
    113.            { maximumAge: 10000, timeout: 10000, enableHighAccuracy: true });   
    114.    }   
    115.     
    116.    function Login(){
    117.        console.log('Login start...');
    119.        var method = 'POST';
    120.        var data = {
    121.            login: 'bp4151@gmail.com',
    122.            password: 'Test'
    123.        };
    124.         
    125.        $.ajax({
    126.            data: data,
    127.            dataType: 'json',
    128.            type: 'POST',
    129.            url: url,
    130.            success: function(data){
    131.                console.log('SUCCESS - ' + JSON.stringify(data));
    132.       
    133.            },
    134.            error: function(data){
    135.                console.log('FAILURE - ' + JSON.stringify(data));
    136.            }
    137.        });
    138.    }
    139.})(window)

    As for using Everlive, it is tempting. I have spent a year trying to develop this app, and have already bailed on one vendor for geolocation, replacing it with my own system. If my other BaaS vendor can't fix what they just broke last week, I may consider Everlive as a total replacement. There are just a few things I need to verify before I do that, but I am considering it. Getting these plugins working is critical to that decision. If I can get the PowerManagement plugin working for background services, and Everlive can handle my BaaS needs, it is a done deal.

    Thanks,
    Bruce
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 30 Aug 2013 Link to this post

    Hello Bruce,

    Yeah, upon checking your suspicion is correct, the problem is missing reference of the PushPlugin js file, which according to your plugin.xml file should be:

    <script type="text/javascript" src="PushNotification.js"></script>

    For more information on that, please refer to Add Includes for the Custom Plugin.

    About the PowerManagement plugin, you can find a working version that you can directly use in Icenium in the following forum thread.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
Back to Top