This plugin integrates the Azure Mobile Engagement (AZME) SDK into your Cordova/PhoneGap Application. It supports both reporting and push features.
Please refer to the Azure Mobile Engagement documentation for more information about the various AZME concepts.
- iOS
- Android
To install the plugin, just add it to your Cordova project using your proper AZME credentials through Cordova variables.
cd <your project>
cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable KEY=<value>
AZME_ENABLE_LOG
:true
|false
, enable both plugin and AZME native logsAZME_REDIRECT_URL
: the url schemes of your application when using redirect actions in your campaign. Must be the url prefix without :// (ex:myapp
to handle urls such asmyapp://shop
)
AZME_IOS_APPID
: the AZME application ID of your iOS applicationAZME_IOS_SDKKEY
: the sdk keyAZME_IOS_COLLECTION
: the collectionAZME_IOS_REACH_ICON
: the icon used for reach notification : must be the name of the resource with its extension (ex:icon.png
)
AZME_ANDROID_APPID
: the AZME application ID of your Android applicationAZME_ANDROID_SDKKEY
: the sdk keyAZME_ANDROID_COLLECTION
: the collextionAZME_ANDROID_REACH_ICON
: the icon used for reach notification : must be the name of the resource without any extension, nor drawable prefix (ex:icon
)AZME_GOOGLE_PROJECT_NUMBER
: the project number used as the GCM (Google Cloud Messaging) sender ID
The AppId, SDKKey and Collection can easily be retrieved from the connection string Endpoint={YOUR_APP_COLLECTION.DOMAIN};SdkKey={YOUR_SDK_KEY};AppId={YOUR_APPID}
Example:
cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable AZME_IOS_COLLECTION=$AZME_IOS_COLLECTION \
--variable AZME_IOS_SDKKEY=$AZME_IOS_SDKKEY \
--variable AZME_IOS_APPID=$AZME_IOS_APPID \
--variable AZME_IOS_REACH_ICON=$AZME_IOS_REACH_ICON \
--variable AZME_ANDROID_GOOGLE_PROJECT_NUMBER=$AZME_ANDROID_GOOGLE_PROJECT_NUMBER \
--variable AZME_ANDROID_APPID=$AZME_ANDROID_APPID \
--variable AZME_ANDROID_COLLECTION=$AZME_ANDROID_COLLECTION \
--variable AZME_ANDROID_SDKKEY=$AZME_ANDROID_SDKKEY \
--variable AZME_ANDROID_REACH_ICON=$AZME_ANDROID_REACH_ICON \
--variable AZME_REDIRECT_URL=$AZME_REDIRECT_URL \
--variable AZME_ENABLE_LOG=$AZME_ENABLE_LOG
To remove the plugin,
cordova plugin rm cordova-plugin-ms-azure-mobile-engagement
Once the deviceready
event has been triggered by the Cordova framework, a AzureEngagement
object is available to interact with the native AZME SDK.
- AzureEngagement.startActivity
- AzureEngagement.endActivity
- AzureEngagement.sendAppInfo
- AzureEngagement.startJob
- AzureEngagement.endJob
- AzureEngagement.sendEvent
- AzureEngagement.onOpenURL
- AzureEngagement.registerForRemoteNotification
- AzureEngagement.getStatus
Start a new activty with the corresponding extra infos object.
AzureEngagement.startActivity(_activityName, _extraInfos,[ _success], [_failure]);
_activityName
: the name of the activity_extraInfos
: a json object containing the extra infos attached to this activity
Ends the current Actvity. Would trigger a new session on the next startActivity
AzureEngagement.endActivity([ _success], [_failure]);
Send an event with the corresponding extra infos object.
AzureEngagement.sendEvent(_eventName, _extraInfos,[ _success], [_failure]);
_eventName
: the name of the event_extraInfos
: a json object containing the extra infos attached to this event
Start an new job with the corresponding extra infos object.
AzureEngagement.startJob(_jobName, _extraInfos,[ _success], [_failure]);
_jobName
: the name of the job_extraInfos
: a json object containing the extra infos attached to this job
End a job previously created by startJob
AzureEngagement.endJob(_jobName,[ _success], [_failure]);
_jobName
: the name of the job
Send App Infos atttached to the currente device.
AzureEngagement.sendAppInfo( _appInfos,[ _success], [_failure]);
_appInfos
: the json object containing the app infos to be sent
Set an event handler when an application specific URL is triggered (from a push campaign for example). The URL scheme must match the one defined in the $AZME_REDIRECT_URL
setting
AzureEngagement.onOpenURL( _urlHandler,[ _success], [_failure]);
#####Params
_urlHandler
: the handler that is passed the url that has been triggerd
#####Example
AzureEngagement.onOpenURL(function(_url) {
console.log("user triggered url/action "+_url);
});
Register the application to receive push notifications on iOS (this function does nothing on the other platforms)
AzureEngagement.registerForPushNotification( [_success], [_failure]);
Returns information about the AZME library
AzureEngagement.getStatus( _statusCallback, [_failure]);
_statusCallback
: the handler that is passed a json object containing information about the AZME library
AzureEngagement.getStatus(function(_info) {
console.log("AZME SDK Version : "+_info.AZMEVersion);
console.log("AZME plugin Version : "+_info.pluginVersion);
});
1.0.0
- Initial Release