Azure / azure-mobile-engagement-cordova

MIT License
9 stars 15 forks source link

Azure Mobile Engagement service has been retired and is no longer available.

Cordova plugin for Azure Mobile Engagement

Introduction

This plugin integrates the Azure Mobile Engagement (AZME) SDK into your Cordova Application. It supports both reporting and push features.

Please refer to the Azure Mobile Engagement documentation for more information about the various AZME concepts.

Supported Platforms

Supported Framework

Installation

To install the plugin, just add it to your Cordova project using your proper AZME credentials through Cordova variables.

cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable KEY=<value>

Generic Variables

iOS Variables

Android Variables

Windows Variables

NB

Example:

cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable AZME_IOS_CONNECTION_STRING=AZME_IOS_CONNECTION_STRING --variable AZME_ANDROID_CONNECTION_STRING=AZME_ANDROID_CONNECTION_STRING 

To remove the plugin,

cordova plugin rm cordova-plugin-ms-azure-mobile-engagement

Location Reporting

Location reporting can be activated by using two additional variables to define which location to report, and whether this reporting should be performed while the application is running in the background:

Example
cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable enableLocation=realtime --variable backgroundReporting=true
Remarks

Push Notification Support

To enable Reach, you need to call Engagement.initializeReach() to register the application to receive push notification.

Engagement.initializeReach( _openURLHandler, _dataPushHandler, [_success], [_failure]);
Params
Example
    onOpenURL = function(_url) {
            console.log("user triggered url/action "+_url);
        };
     onDataPushReceived = function(_category,_body) {
            if (_category=="png")
                str += '<img src="https://github.com/Azure/azure-mobile-engagement-cordova/raw/master/data:image/png;base64,'+_body+'" width="128" height="128" />';
            else
                str += _body;
            // ...
        };  
     Engagement.initializeReach(onOpenURL,onDataPushReceived);
Notes

Public Interface

Once the deviceready event has been triggered by the Cordova framework, a Engagement object is available to interact with the native AZME SDK.

Engagement.startActivity

Start a new activty with the corresponding extra infos object.

Engagement.startActivity(_activityName, _extraInfos,[ _success], [_failure]);
Params

Engagement.endActivity

Ends the current Actvity. Would trigger a new session on the next startActivity

Engagement.endActivity([ _success], [_failure]);

Engagement.sendEvent

Send an event with the corresponding extra infos object.

Engagement.sendEvent(_eventName, _extraInfos,[ _success], [_failure]);
Params

Engagement.startJob

Start an new job with the corresponding extra infos object.

Engagement.startJob(_jobName, _extraInfos,[ _success], [_failure]);
Params

Engagement.endJob

End a job previously created by startJob

Engagement.endJob(_jobName,[ _success], [_failure]);
Params

Engagement.sendSessionEvent

Send a session event

Engagement.sendSessionEvent(_eventName, _extraInfos ,[ _success], [_failure]);

Engagement.sendSessionError

Send a session error

Engagement.sendSessionError(_error, _extraInfos ,[ _success], [_failure]);

Engagement.sendError

Send an error

Engagement.sendError(_error, _extraInfos ,[ _success], [_failure]);

Engagement.sendJobEvent

Send a job event

Engagement.sendError(_eventName, _jobName, _extraInfos ,[ _success], [_failure]);

Engagement.sendJobError

Send a job error

Engagement.sendError(_error, _jobName, _extraInfos ,[ _success], [_failure]);

Engagement.sendAppInfo

Send App Infos atttached to the currente device.

Engagement.sendAppInfo( _appInfos,[ _success], [_failure]);
Params

Engagement.sendCrash

Report crashes manually (Windows Only)

Engagement.sendCrash( _crashId, _crash,[ _success], [_failure]);
Params

Engagement.setEnabled

Active or deactivate the agent

Engagement.setEnabled( _enabled,[ _success], [_failure]);
Params

Engagement.isEnabled

Returns the status of the agent

Engagement.isEnabled(function(_enabled){...},[_failure]);

Engagement.requestPermissions

Allow the user to autorize the permissions needed for the proper execution of the AZME plugin. By default, there's no need for a additional permissions, but if you've enabled the location reporting, this function must be called to let the user allow the location based permissions (ACCESS_FINE_LOCATION and/or ACCESS_COARSE_LOCATION)

Engagement.requestPermissions([_success], [_failure]);
Notes
Example
Engagement.requestPermissions(function(_ret) {
                console.log("permissions = "+JSON.stringify(_ret));
    });

Engagement.getStatus

Returns information about the AZME plugin.

Engagement.getStatus( _statusCallback, [_failure]);
Params
Example
    Engagement.getStatus(function(_info) {
            console.log("AZME native Version : "+_info.nativeVersion);
            console.log("AZME plugin Version : "+_info.pluginVersion);
            console.log("Device ID : "+_info.deviceId); 
        });

History

3.3.0
3.2.3
3.2.2
3.2.1
3.2.0
3.1.0
3.0.2
3.0.1
3.0.0
2.3.1
2.2.0
2.1.1
2.1.0
2.0.1
2.0.0
1.0.0

Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.