Coder Social home page Coder Social logo

criccle / mxpushnotifications Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonmartyr/mxpushnotifications

0.0 2.0 0.0 70.28 MB

Mendix Push Notifications Connector

License: Other

JavaScript 2.98% HTML 0.94% Java 25.35% Ruby 0.17% CSS 70.56%

mxpushnotifications's Introduction

Mendix Push Notifications

Documentation has been moved to Mendix 6 How-To's

Push Notifications let your application notify a user of events even when the user is not actively using the application. This is a native capability provided by both Android and iOS devices and made available via Google Cloud Messaging (GCM) and Apple Push Notifications service (APNs). This project is meant to make it easy for Mendix developers who want to include Push Notifications capability into their Mendix hybrid mobile application.

Step 1 - Import the PushNotifications module from the App Store

Same as Mendix 6 How-To

Step 2 - Install module dependencies

Same as Mendix 6 How-To

Step 3 - Include the push notifications snippet in the application's layouts

Same as Mendix 6 How-To

Step 4 - Start connectors from your After Startup microflow

Add Microflow Services to your After Startup for each callback defined in your index.html.

Step 5 - Set up the administration pages

Same as Mendix 6 How-To

Step 6: Set up project security for your module

Same as Mendix 6 How-To

Step 7 - Deploy your app

Same as Mendix 6 How-To

Step 8 - Set up access to APNs and GCM

Same as Mendix 6 How-To

Step 9 - Missingno

Missing from Mendix documentation???

Step 10 - Build the hybrid mobile application

Add the following lines of code to your config.xml:

<preference name="android-build-tool" value="gradle" />
<gap:plugin name="phonegap-plugin-push" source="npm" version="1.6.0">
            <param name="SENDER_ID" value="XXXXXXXXXXXX" />
</gap:plugin>

Note that Action Buttons require a newer version of the phonegap-plugin-push than before.

Add the following script tags to your index.html These define the callback and they should be be defined like such:

<script>
firstCallback = function(data) {
    // For test purposes
    // console.log(JSON.stringify(data));
    $.ajax({
        url:"YOUR URL HERE",
        type:"POST",
        data:JSON.stringify(data),
        contentType:"application/json; charset=utf-8",
        dataType:"json"
    });
},

secondCallback = function(data) {
    // For test purposes
    // console.log(JSON.stringify(data));                
    $.ajax({
        url:"YOUR URL HERE",
        type:"POST",
        data:JSON.stringify(data),
        contentType:"application/json; charset=utf-8",
        dataType:"json"
    });               
},

thirdCallback = function(data) {
    // For test purposes
    // console.log(JSON.stringify(data));                
    $.ajax({
        url:"YOUR URL HERE",
        type:"POST",
        data:JSON.stringify(data),
        contentType:"application/json; charset=utf-8",
        dataType:"json"
    });        
}
</script> 

Make sure you don't change the callback function names, otherwise the module will not work. You can also use XMLHTTPRequests to send data, but I prefer this way. If you are implementing it with the above, you also need to include jquery in your Phonegap zip. I have added jquery.min.js to the /js/ folder (downloaded from Google).

Extending functionality to make callbacks more useful

The Action Buttons that are shown in your notification menu are outside of Mendix context. Therefore you need to add the callbacks to your index.html (so it's always accessible). To extend the callback functionality you can edit the GCMConnection.java file and send extra data along. An example:

payload.put("awesomeness", message.getawesomeness());
//the notId attribute is added so each notification is shown instead of replacing the previous one sent from your application.
payload.put("notId", message.getnotId());

//New bit of code that addes ActionButtons to your notification. The constructor has the following parameters: Title, callback function title, foreground (this defines if clicking the Action Button should open the app or handle things in the background).
ActionButton firstAction = new ActionButton("YEAH!", "firstCallback", false);
ActionButton secondAction = new ActionButton("NO :-(", "secondCallback", false);
ActionButton thirdAction = new ActionButton("Not sure", "thirdCallback", false);

actions.add(firstAction);
actions.add(secondAction);
actions.add(thirdAction);
payload.put("actions", actions);

As you can see in the above code three action buttons are added. If you want more or less. Simply add/remove them from the code and you index.html callbacks. I have tested this with up to three buttons and that works perfectly.

Known bugs and errors

Only tested on Android.

mxpushnotifications's People

Contributors

simo101 avatar rjprinse avatar criccle avatar andries-smit avatar simonmartyr avatar kevinvlaanderen avatar sjoerdbreur avatar carlos-salinas avatar reinouts avatar dlhartveld avatar ismailhabib avatar rcatersels avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.