Problem integrating IONIC sdk

Hi,

i was integrating countly-sdk-js in my ionic application. I installed the sdk with

cordova plugin add countly-sdk-js@19.9.3

in the file i declare countly variable like this on top of the file

declare var Countly;
 
now in the middle of file i am doing this
 
Countly.init(SERVER_URL,APP_KEY);
 
now when i run the app on physical IOS device. i am getting this error Can’t find variable: Countly.
0

Comments

5 comments
  • You wouldn't declare Countly yourself. Cordova docs mention to include these files for Ionic:

    In your index.html, use the following lines:

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

    So when you do that Countly.js will introduce that Countly variable. 

     

     

    0
    Comment actions Permalink
  • your ionic example said to do it. that's why i did.

     

    Now when i remove the countly declaration from the top. Typescript gives me error

     

    0
    Comment actions Permalink
  • I see. I'll ping a developer who knows more about that example code.

    0
    Comment actions Permalink
  • thank you for your coorperation. i actually fixed that issue but now i am facing issue with push notification. i am handling certificate stuff right now. i will upload proper certificate and then try the notification again if the issue still persist i will ping here

    0
    Comment actions Permalink
  • for anyone seeing this post in the future. The issue was that countly init code was running before device ready. So app was not able to find countly variable so what i did. 

    Import the Platform module of ionic and register a ready event and inside that event i initialized countly. Now it's working fine

    0
    Comment actions Permalink

Please sign in to leave a comment.