Flutter教程

HyperTrack

Contents

HyperTrack cordova plugin wrapper for Ionic Native. Location-based services provider. Make sure to include your publishable key at config.xml (see HyperTrack Cordova Setup).

https://github.com/hypertrack/hypertrack-cordova

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic HyperTrack插件的安装(Installation)

ionic cordova plugin add cordova-plugin-hypertrack npm install @ionic-native/hyper-track
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/hyper-track

Ionic HyperTrack插件支持的平台(Supported Platforms)

  • Android

Ionic HyperTrack插件的用法(Usage)

import { HyperTrack } from '@ionic-native/hyper-track/ngx';

constructor(private hyperTrack: HyperTrack) { }

// Check if app has location permissions enabled
this.hyperTrack.checkLocationPermission().then(response => {
  // response (String) can be "true" or "false"
  if (response != "true") {
    // Ask for permissions
    this.hyperTrack.requestPermissions().then(response => {}, error => {});
  }
}, error => {});

// Check if app has location services enabled
this.hyperTrack.checkLocationServices().then(response => {
  // response (String) can be "true" or "false"
  if (response != "true") {
    // Request services to be enabled
    this.hyperTrack.requestLocationServices().then(response => {}, error => {});
  }
}, error => {});

// First set the current user. This can be done via getOrCreateUser() or setUserId()
this.hyperTrack.setUserId("xxx").then(user => {
  // user (String) is a String representation of a User's JSON

  this.hyperTrack.startTracking().then(userId => {}, trackingError => {});

  this.hyperTrack.createAndAssignAction('visit', 'lookupId','address', 20.12, -100.3).then(action => {
    // Handle action. It's a String representation of the Action's JSON. For example:
    // '{"eta":"Jul 17, 2017 12:50:03 PM","assigned_at":"Jul 17, 2017 12:34:38 PM",,"distance":"0.0",...}'
  }, error => {});

  // You can complete an action with completeAction() or completeActionWithLookupId()
  this.hyperTrack.completeAction('action-id').then(response => {
    // Handle response (String). Should be "OK".
  }, error => {});

  this.hyperTrack.getCurrentLocation().then(location => {
    // Handle location. It's a String representation of a Location's JSON.For example:
    // '{"mAccuracy":22.601,,"mLatitude":23.123456, "mLongitude":-100.1234567, ...}'
  }, error => {});

  this.hyperTrack.stopTracking().then(success => {
    // Handle success (String). Should be "OK".
  }, error => {});

}, error => {});*