3

I need to implement PubNub pushnotification in my MobileFirst project.

For that implementation i done the following things.

In my android native folder :assets->www->default->worklight->cordova_plugins.js

Here I added the following code

 {
        "file": "plugins/org.apache.cordova.pushnotification/www/pushnotification.js",
        "merges": [
            "window.plugins.pushNotification"
        ]
    }

In android native folder assets->www->default->js->main.js file i added the following code

var pushNotification = window.plugins.pushNotification;

    pushNotification.register(
        successHandler, 
        errorHandler, 
        {
            'senderID':'projectID'
        }
    );

    function successHandler(result) {
        alert('Success: '+ result);
    }
    function errorHandler(error) {
        alert('Error: '+ error);
    }

And I run this code on my android device. When I inspect my android device. i am getting the following error on my concole

Uncaught Error: Module undefined does not exist. in cordova.js file

Is this cordova plugin issue?

How can I configure cordova plugin in MobileFirst project?

Please suggest..

Kichu
  • 1,641
  • 4
  • 21
  • 28

1 Answers1

2

You should not edit main.js in the native\www folder.

You need to edit the main.js that is in apps\your-app\common\js\main.js. This file is later copied into the native folder.

If you edit the file in the native folder and then build the project, your changes are lost - they will be overwritten with what that is in common\js\main.js...

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Then how can i implement this cordova plugin in MobileFirst project? – Kichu Nov 30 '15 at 08:52
  • What does that have to do with the error you did above?! Read the training materials for developing Cordova plug-ins in the MFP developer center. – Idan Adar Nov 30 '15 at 09:19
  • I just tried to add the pushnotification plugin to native android code,using the above method. From there getting the Error. I am not clear about your last comment – Kichu Nov 30 '15 at 10:04
  • If we need to add this plugin to MobileFirst the only way to develop cordova plugin through MFP ? – Kichu Nov 30 '15 at 10:06
  • Yes. Or you can use MobileFirst 7.1 where you can create Cordova apps instead of MFP Hybrid. With Cordova apps it will be easier to add Cordova plug-ins. – Idan Adar Nov 30 '15 at 10:31