azure-mobile-engagement-cor.../README.md

362 строки
13 KiB
Markdown
Исходник Постоянная ссылка Обычный вид История

# Azure Mobile Engagement service has been retired and is no longer available.
2015-09-20 22:13:12 +03:00
Cordova plugin for Azure Mobile Engagement
2015-05-19 22:23:20 +03:00
----
Introduction
--
2015-10-27 00:35:00 +03:00
This plugin integrates the Azure Mobile Engagement (AZME) SDK into your Cordova Application. It supports both *reporting* and *push* features.
2015-05-19 22:23:20 +03:00
2015-10-28 22:53:42 +03:00
*Please refer to the Azure Mobile Engagement documentation for more information about the various AZME concepts.*
2015-05-19 22:23:20 +03:00
Supported Platforms
--
* iOS
* Android
2016-06-09 19:47:55 +03:00
* Windows 10 Universal & Windows 8.1
2015-05-19 22:23:20 +03:00
2015-10-27 00:35:00 +03:00
Supported Framework
--
* Cordova
* PhoneGap
* CocoonJS
* CrossWalk
2015-05-19 22:23:20 +03:00
Installation
--
To install the plugin, just add it to your Cordova project using your proper AZME credentials through Cordova variables.
```sh
2015-06-07 23:43:59 +03:00
cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable KEY=<value>
2015-05-19 22:23:20 +03:00
```
#### Generic Variables
2016-03-23 23:46:24 +03:00
- `AZME_ENABLE_PLUGIN_LOG` : `true`|`false`, enable logs from the Cordova Wrapper (recommended for development)
- `AZME_ENABLE_NATIVE_LOG` : `true`|`false`, enable logs from the AZME native SDK
- `AZME_ACTION_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 as `myapp://shop`)
2015-05-19 22:23:20 +03:00
#### iOS Variables
2015-09-20 22:13:12 +03:00
- `AZME_IOS_CONNECTION_STRING` : the iOS connection string (to retrieve from the AZME portal)
- `AZME_IOS_REACH_ICON` : the icon used for reach notification : must be the name of the resource with its extension (ex: `mynotificationicon.png`), and the icon file must be added into your iOS project with XCode (using the Add Files Menu)
2015-05-19 22:23:20 +03:00
#### Android Variables
2016-06-09 19:47:55 +03:00
- `AZME_ANDROID_CONNECTION_STRING` : the Android connection string (to retrieve from the AZME portal)
2016-12-13 23:21:22 +03:00
- `AZME_ANDROID_REACH_ICON` : the icon used for reach notification
- must be the name of the resource without any extension, nor drawable prefix (ex: `mynotificationicon`)
- the icon file must be copied into your android project with its extension (ex: `platforms/android/res/drawable/mynotificationicon.png`)
2015-10-07 19:42:54 +03:00
- `AZME_ANDROID_GOOGLE_PROJECT_NUMBER` : the project number used as the GCM (Google Cloud Messaging) sender ID
2016-06-09 19:47:55 +03:00
#### Windows Variables
- `AZME_WINDOWS_CONNECTION_STRING` : the WINDOWS connection string (to retrieve from the AZME portal)
#### NB
* Only the `AZME_*_CONNECTION_STRING` are required : all the other variables are optionals.
2015-05-19 22:23:20 +03:00
Example:
```sh
2015-09-07 00:35:59 +03:00
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
2015-05-19 22:23:20 +03:00
```
To remove the plugin,
```sh
2015-06-07 23:43:59 +03:00
cordova plugin rm cordova-plugin-ms-azure-mobile-engagement
2015-05-19 22:23:20 +03:00
```
2015-09-20 22:13:12 +03:00
2015-10-27 00:35:00 +03:00
Location Reporting
--
2015-10-27 21:48:04 +03:00
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:
2015-11-12 00:25:50 +03:00
* `--variable enableLocation` : `lazyarea`|`realtime`|`finerealtime`
2015-10-27 21:48:04 +03:00
* `--variable backgroundReporting` : `true`|`false`
2015-10-27 00:35:00 +03:00
##### Example
```sh
2015-10-27 21:48:04 +03:00
cordova plugin add cordova-plugin-ms-azure-mobile-engagement --variable enableLocation=realtime --variable backgroundReporting=true
2015-10-27 00:35:00 +03:00
```
##### Remarks
2015-05-19 22:23:20 +03:00
2015-10-27 00:35:00 +03:00
* By default, location report is being deactivated.
2015-10-27 21:48:04 +03:00
* Internally, some additional plugins are being added to your project, but they will be automatically removed when the AZME plugin is being removed
* `cordova-plugin-ms-azure-mobile-engagement-lazyarea-location`
* `cordova-plugin-ms-azure-mobile-engagement-runtime-location`
* `cordova-plugin-ms-azure-mobile-engagement-fineruntime-location`
* `cordova-plugin-ms-azure-mobile-engagement-foreground-reporting`
* `cordova-plugin-ms-azure-mobile-engagement-background-reporting`
2016-03-23 23:46:24 +03:00
* If you are targetting AndroidM, your application needs to call `Engagement.requestPermissions`at some point (cf. below)
* For IOS, you can also add `--variable AZME_IOS_LOCATION_DESCRIPTION : <desc> ` to define the message that will be displayed to the end user in the permission dialog
2016-06-09 19:47:55 +03:00
* Not supported on Windows
2015-10-27 00:35:00 +03:00
2016-03-23 23:46:24 +03:00
Push Notification Support
2015-05-19 22:23:20 +03:00
--
2016-03-23 23:46:24 +03:00
To enable Reach, you need to call
`Engagement.initializeReach()` to register the application to receive push notification.
```javascript
Engagement.initializeReach( _openURLHandler, _dataPushHandler, [_success], [_failure]);
```
##### Params
* `_onOpenURLHandler`: the function to be called when an application specific URL is triggered (from a push campaign for example). The URL scheme must match the one defined in the `$AZME_ACTION_URL` setting
* `_dataPushHandler`: the function handler to receive the data push. The function needs to accept two parameters : the `category` , and the `body`
##### Example
```javascript
onOpenURL = function(_url) {
console.log("user triggered url/action "+_url);
};
onDataPushReceived = function(_category,_body) {
if (_category=="png")
str += '<img src="data:image/png;base64,'+_body+'" width="128" height="128" />';
else
str += _body;
// ...
};
Engagement.initializeReach(onOpenURL,onDataPushReceived);
```
2015-05-19 22:23:20 +03:00
2016-03-23 23:46:24 +03:00
##### Notes
* on IOS, this call will ask the user to autorize push notifications for your application, so it is recommended to trigger that call at the proper time (ie: once the users are engaged into your application)
* If the body contains non-text data, it will be received encoded in base64 format
* If the data is an image, it can be directly displayed using the prefix `data:image/png;base64` (cf. example)
* If you want to extract the data bytes, you would need to use the `btoa()` function to convert base64 to binary
2016-06-09 19:47:55 +03:00
* Reach is not available on Windows yet!
2016-03-23 23:46:24 +03:00
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
* Engagement.endActivity
* Engagement.sendAppInfo
* Engagement.startJob
* Engagement.endJob
* Engagement.sendEvent
* Engagement.getStatus
* Engagement.requestPermissions
* Engagement.sendSessionEvent
* Engagement.sendSessionError
* Engagement.sendError
* Engagement.sendJobEvent
* Engagement.sendJobError
2016-06-09 19:47:55 +03:00
* Engagement.sendCrash
2016-06-23 10:36:29 +03:00
* Engagement.isEnabled
* Engagement.setEnabled
2016-03-23 23:46:24 +03:00
### Engagement.startActivity
2015-05-19 22:23:20 +03:00
Start a new activty with the corresponding extra infos object.
```javascript
2016-03-23 23:46:24 +03:00
Engagement.startActivity(_activityName, _extraInfos,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
##### Params
* `_activityName`: the name of the activity
* `_extraInfos`: a json object containing the extra infos attached to this activity
2016-03-23 23:46:24 +03:00
### Engagement.endActivity
2015-05-19 22:23:20 +03:00
Ends the current Actvity. Would trigger a new session on the next startActivity
```javascript
2016-03-23 23:46:24 +03:00
Engagement.endActivity([ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
2016-03-23 23:46:24 +03:00
### Engagement.sendEvent
2015-05-19 22:23:20 +03:00
Send an event with the corresponding extra infos object.
```javascript
2016-03-23 23:46:24 +03:00
Engagement.sendEvent(_eventName, _extraInfos,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
##### Params
* `_eventName`: the name of the event
* `_extraInfos`: a json object containing the extra infos attached to this event
2016-03-23 23:46:24 +03:00
### Engagement.startJob
2015-05-19 22:23:20 +03:00
Start an new job with the corresponding extra infos object.
```javascript
2016-03-23 23:46:24 +03:00
Engagement.startJob(_jobName, _extraInfos,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
##### Params
* `_jobName`: the name of the job
* `_extraInfos`: a json object containing the extra infos attached to this job
2016-03-23 23:46:24 +03:00
### Engagement.endJob
2015-05-19 22:23:20 +03:00
End a job previously created by startJob
```javascript
2016-03-23 23:46:24 +03:00
Engagement.endJob(_jobName,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
##### Params
* `_jobName`: the name of the job
2016-03-23 23:46:24 +03:00
### Engagement.sendSessionEvent
Send a session event
2015-05-19 22:23:20 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.sendSessionEvent(_eventName, _extraInfos ,[ _success], [_failure]);
```
### Engagement.sendSessionError
Send a session error
```javascript
Engagement.sendSessionError(_error, _extraInfos ,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
2016-03-23 23:46:24 +03:00
### Engagement.sendError
Send an error
2015-05-19 22:23:20 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.sendError(_error, _extraInfos ,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
2016-03-23 23:46:24 +03:00
### Engagement.sendJobEvent
Send a job event
2015-05-19 22:23:20 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.sendError(_eventName, _jobName, _extraInfos ,[ _success], [_failure]);
2015-05-19 22:23:20 +03:00
```
2015-09-20 22:13:12 +03:00
2016-03-23 23:46:24 +03:00
### Engagement.sendJobError
Send a job error
2015-09-20 22:13:12 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.sendError(_error, _jobName, _extraInfos ,[ _success], [_failure]);
```
### Engagement.sendAppInfo
Send App Infos atttached to the currente device.
```javascript
Engagement.sendAppInfo( _appInfos,[ _success], [_failure]);
2015-09-20 22:13:12 +03:00
```
2015-10-27 00:35:00 +03:00
##### Params
2016-03-23 23:46:24 +03:00
* `_appInfos`: the json object containing the app infos to be sent
2015-09-20 22:13:12 +03:00
2016-06-09 19:47:55 +03:00
### Engagement.sendCrash
Report crashes manually (Windows Only)
```javascript
Engagement.sendCrash( _crashId, _crash,[ _success], [_failure]);
```
##### Params
* `_crashId`: the crashid argument is a string used to identify the type of the crash.
* `_crash`: usually the stack trace of the crash as a string.
2016-06-23 10:36:29 +03:00
### Engagement.setEnabled
Active or deactivate the agent
```javascript
Engagement.setEnabled( _enabled,[ _success], [_failure]);
```
##### Params
* `_enabled`: boolean
### Engagement.isEnabled
Returns the status of the agent
```javascript
Engagement.isEnabled(function(_enabled){...},[_failure]);
```
2015-09-20 22:13:12 +03:00
2016-03-23 23:46:24 +03:00
### 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`)
2015-09-20 22:13:12 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.requestPermissions([_success], [_failure]);
2015-09-20 22:13:12 +03:00
```
2016-03-23 23:46:24 +03:00
##### Notes
* Returns the list of permissions that have been asked, ans whether the user has allowed them or not
* This function does nothing on platforms other than Android M.
2015-09-20 22:13:12 +03:00
2016-03-23 23:46:24 +03:00
##### Example
2015-05-19 22:23:20 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.requestPermissions(function(_ret) {
console.log("permissions = "+JSON.stringify(_ret));
});
2015-05-19 22:23:20 +03:00
```
2016-03-23 23:46:24 +03:00
### Engagement.getStatus
2015-09-20 22:13:12 +03:00
Returns information about the AZME plugin.
2015-05-19 22:23:20 +03:00
```javascript
2016-03-23 23:46:24 +03:00
Engagement.getStatus( _statusCallback, [_failure]);
2015-05-19 22:23:20 +03:00
```
##### Params
* `_statusCallback`: the handler that is passed a json object containing information about the AZME library
2016-09-20 09:27:03 +03:00
* `nativeVersion`: the version number of the AZME native SDK
* `pluginVersion`: the version number of the Cordova plugin
* `deviceId`: the deviceId as defined by AZME
* `isEnabled`: if the plugin has been enabled (iOS only)
* `notificationGranted`: if the user has alredy accepted to receive notifications (iOS only)
2015-05-19 22:23:20 +03:00
##### Example
```javascript
2016-03-23 23:46:24 +03:00
Engagement.getStatus(function(_info) {
console.log("AZME native Version : "+_info.nativeVersion);
2015-09-08 22:49:33 +03:00
console.log("AZME plugin Version : "+_info.pluginVersion);
2016-09-20 09:27:03 +03:00
console.log("Device ID : "+_info.deviceId);
2015-09-07 00:35:59 +03:00
});
2015-05-19 22:23:20 +03:00
```
History
----
##### 3.3.0
* Updated iOS SDK to 4.1.0 (iOS 6 deprecation, iOS 11 support)
* Updated iOS SDK to 4.3.1 (Android O support)
2016-12-13 23:21:22 +03:00
##### 3.2.3
* Updated iOS SDK to 4.0.1
2016-10-17 21:38:15 +03:00
##### 3.2.2
* Fixed location reporting support for Cordova 6.3.x+
* Fixed permissions support when using Fine Location reporting on Android
* Updated Android SDK to 4.2.3
* Updated Windows SDK to 2.0.1
2016-09-20 09:27:03 +03:00
##### 3.2.1
* Added `permissionAllowed in `getStatus()
2016-09-27 09:49:33 +03:00
* Fixed exception during first run on Windows
##### 3.2.0
* Updated iOS SDK to 4.0.0 to support iOS 10 / XCode 8
2016-06-09 19:47:55 +03:00
##### 3.1.0
* Added Windows support (Analytics only)
2016-09-27 09:49:33 +03:00
* Fixed `SendAppInfos` on Android
2016-06-23 10:36:29 +03:00
* Added `SetEnabled`/`IsEnabled` interface
2016-06-09 19:47:55 +03:00
2016-04-18 20:00:10 +03:00
##### 3.0.2
* Fixed possible duplicate notifications
2016-03-29 23:20:49 +03:00
##### 3.0.1
2016-06-23 10:36:29 +03:00
* Fixed `onOpenURL` not being called when using a notification with no additional view
2016-03-23 23:46:24 +03:00
2016-03-29 23:20:49 +03:00
##### 3.0.0
2016-03-23 23:46:24 +03:00
* API Breaking Change
* `AZME_ENABLE_NATIVE_LOG`/`AZME_ENABLE_PLUGIN_LOG` instead of `AZME_ENABLE_LOG`
* `AZME_ACTION_URL` instead of `AZME_REDIRECT_URL`
* `initializeReach` instead of `registerForPushNotification`/`onHandleURL`/`onDataPushReceived`
2016-04-18 20:03:01 +03:00
* Category is set to `null` instead of `None` if not defined within a campaign
2016-06-09 19:47:55 +03:00
* APIs use `Engagement.<APIName>` convention instead of `AzureEngagement.<APIName>`
2016-03-23 23:46:24 +03:00
* Added `AZME_IOS_LOCATION_DESCRIPTION` variable
* Fix Location reporting hooks
##### 2.3.1
* Added Android M Support
* Added reporting functions
* Refactor underlying code to share the same base code with the AZME Unity SDK
##### 2.2.0
2015-10-27 00:35:00 +03:00
* Added location reporting
2016-03-23 23:46:24 +03:00
##### 2.1.1
2015-10-02 01:26:23 +03:00
* Refactor Native <-> JS Bridge
2016-03-23 23:46:24 +03:00
##### 2.1.0
2015-09-20 22:13:12 +03:00
* Added data push support
2016-03-23 23:46:24 +03:00
##### 2.0.1
2015-09-20 22:13:12 +03:00
* Added debug logs
2016-03-23 23:46:24 +03:00
##### 2.0.0
2015-09-20 22:13:12 +03:00
* Upgraded Native Android SDK to v4.1.0
2015-09-07 00:35:59 +03:00
* Upgraded Native iOS SDK to v3.1.0
* Using the ConnectionString instead of the former AppID/SDKKey/Collection
2015-05-19 22:23:20 +03:00
2016-03-23 23:46:24 +03:00
##### 1.0.0
2015-05-19 22:23:20 +03:00
* Initial Release
2016-10-11 09:21:11 +03:00
## Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.