Giter Site home page Giter Site logo

kurtisf / phonegap-ua-push Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urbanairship/urbanairship-cordova

0.0 2.0 0.0 102.63 MB

Urban Airship integration with Phonegap

License: Other

CSS 11.08% HTML 1.07% JavaScript 25.46% Java 4.50% Objective-C 57.86% C 0.03%

phonegap-ua-push's Introduction

Urban Airship PhoneGap/Cordova Plugin

This plugin supports PhoneGap/Cordova apps running on both iOS and Android. Full documentation is available here.

Requirements:

Contributing Code

We accept pull requests! If you would like to submit a pull request, please fill out and submit a Code Contribution Agreement.

Issues

Please contact [email protected] for any issues integrating or using this plugin.

Migration

A migration guide for newer releases of the plugin can be found here.

Installation

  1. Install this plugin using PhoneGap/Cordova CLI:

     cordova plugin add urbanairship-cordova
    
  2. Modify the config.xml file to contain (replacing with your configuration settings):

     <!-- Urban Airship app credentials -->
     <preference name="com.urbanairship.production_app_key" value="Your Production App Key" />
     <preference name="com.urbanairship.production_app_secret" value="Your Production App Secret" />
     <preference name="com.urbanairship.development_app_key" value="Your Development App Key" />
     <preference name="com.urbanairship.development_app_secret" value="Your Development App Secret" />
    
     <!-- Required for Android. -->
     <preference name="com.urbanairship.gcm_sender" value="Your GCM Sender ID" />
    
     <!-- If the app is in production or not -->
     <preference name="com.urbanairship.in_production" value="true | false" />
    
     <!-- Optional config values -->
    
     <!-- Enable push when the application launches -->
     <preference name="com.urbanairship.enable_push_onlaunch" value="true | false" />
     
     <!-- Enable Analytics when the application launches -->
     <!-- Warning: Features that depend on analytics being enabled may not work properly if analytics is disabled (reports, location segmentation, region triggers, push to local time). -->
     <preference name="com.urbanairship.enable_analytics" value="true | false" />
    
     <!-- Override the Android notification icon -->
     <preference name="com.urbanairship.notification_icon" value="ic_notification" />
    
     <!-- Specify the notification accent color for Android API 21+ (Lollipop) -->
     <preference name="com.urbanairship.notification_accent_color" value="#0000ff" />
    
     <!-- Clear the iOS badge on launch -->
     <preference name="com.urbanairship.clear_badge_onlaunch" value="true | false" />
    
  3. If your app supports Android API < 14, then you have to manually instrument any Android Activities to have proper analytics. See Instrumenting Android Analytics.

Basic Example

// Register for any Urban Airship events
document.addEventListener("urbanairship.registration", function (event) {
    if (event.error) {
        console.log('There was an error registering for push notifications')
    } else {
        console.log("Registered with ID: " + event.channelID)
    } 
})

document.addEventListener("urbanairship.push", function (event) {
    console.log("Incoming push: " + event.message)
})

// Set tags on a device, that you can push to
UAirship.setTags(["loves_cats", "shops_for_games"], function () {
    UAirship.getTags(function (tags) {
        tags.forEach(function (tag) {
            console.log("Tag: " + tag)
        })
    })
})

// Set an alias, this lets you tie a device to a user in your system
UAirship.setAlias("awesomeuser22", function () {
    UAirship.getAlias(function (alias) {
        console.log("The user formerly known as " + alias)
    })
})

// Enable user notifications (will prompt the user to accept push notifications)
UAirship.setUserNotificationsEnabled(true, function (enabled) {
    console.log("User notifications are enabled! Fire away!")
})

Sample

A sample can be found in Example. To run it, copy the files:

  • Example/index.html to www/index.html
  • Example/css/* to www/css
  • Example/js/* to www/js

Add the device plugin: cordova plugin add org.apache.cordova.device

phonegap-ua-push's People

Contributors

rlepinski avatar marc-scig avatar crow avatar mhooge avatar sarriaroman avatar hcrowell avatar textpla-in avatar ericholscher avatar danielcompton avatar vpolouchkine avatar mdpatrick avatar gschammah avatar krebernisak avatar macdonst avatar sandstrom avatar zofrex avatar

Watchers

James Cloos avatar Kurt Fickewirth 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.