0

I followed the steps given in below link.

https://community.oracle.com/community/cloud_computing/oracle-cloud-developer-solutions/blog/2016/08/16/your-first-push-notification-based-oracle-jet-hybrid-application

But I am unable to register for Push Notification while logging in.

function registerDeviceForMCSPush(mcsBackend) {  
    var defer = $.Deferred();  
    if (typeof PushNotification !== 'undefined') {  
        try {  
            var push = PushNotification.init({  
                "android": {  
                    // TODO replace Google Project Number here  
                    senderID: "55926"
                }  
            });  
            push.on('registration', function (data) {  
                var regId = data.registrationId;  
                deviceHandshakeforCordova(mcsBackend, regId);  
            });  
            push.on('notification', function (data) {  
                alert("Push Notification from Oracle MCS: " + data.message);  
            });  
            push.on('error', function (e) {  
                alert("Push Notification Error=" + e.message);  
            });  
        } catch (ex) {  
            alert("Error registering device with MCS" + ex);  
            defer.reject();  
        }  
    } else {  
        alert("PushNotification NOT Defined!");  
        defer.reject();  
    }  
    return $.when(defer);  
}  

I receive the alert message "Push Notification is not defined" from the code

Janaki Narayanan
  • 523
  • 6
  • 24
  • What link are you referring too? This one?: https://community.oracle.com/community/cloud_computing/oracle-cloud-developer-solutions/blog/2016/08/16/your-first-push-notification-based-oracle-jet-hybrid-application – Chris Muir Apr 01 '17 at 02:42
  • Are you sure that's the alert message you're getting? Your code doesn't have a message that matches what you describe. Rather the final alert has something similar "PushNotification NOT Defined!" – Chris Muir Apr 01 '17 at 02:43
  • you can find that alert message in else part of the code else { alert("PushNotification NOT Defined!"); defer.reject(); } – Janaki Narayanan Apr 01 '17 at 06:09

1 Answers1

0

Oracle JET based on Cordova doesn't come with push notifications out of the box, rather it's typical to add a 3rd party Cordova plugin such as https://github.com/phonegap/phonegap-plugin-push. I suspect the error you're getting is indicating you haven't added the 3rd party plugin.

You add this to your JET project by

a) cd'ing into your application directory then cd'ing into the hybrid directory

b) executing the following command:

cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXXX"

...where XXXXXXX maps to the project number in the Firebase developer console.

This video explains the complete set of steps for setting up push notifications in JET with Oracle Mobile Cloud Service inline with the steps from the article and should provide you assistance in learning how it all works: https://youtu.be/6n-1-bo2_iQ

Chris Muir
  • 445
  • 2
  • 8
  • I have added the plugin as described in the link.I have added the plugin to hybrid folder of the project (Since it asked for the cordova project) – Janaki Narayanan Apr 01 '17 at 06:10