danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.4k stars 2.42k forks source link

Property 'LAUNCH_MODE' does not exist on type 'LaunchNavigator'. #2682

Closed gabrielrbarbosa closed 2 years ago

gabrielrbarbosa commented 6 years ago

On Ionic Native docs v3 - Launch Navigator it says that launchModeGoogleMaps option accept launchnavigator.LAUNCH_MODE.TURN_BY_TURN.

But when I use it this error shows: Property 'LAUNCH_MODE' does not exist on type 'LaunchNavigator'.

I got it working using just string values like launchModeGoogleMaps: 'turn-by-turn'

dpa99c commented 5 years ago

The LAUNCH_MODE constants are defined by the JS plugin API but not currently exposed in the Ionic Native Typescript wrapper

bkrajendra commented 4 years ago

Whats the solution for this?

dchitiva-ccracks commented 3 years ago

this.launchOptions = { start: [lat, long], launchModeGoogleMaps: 'turn-by-turn', };

mikenetcode commented 3 years ago

I had the same problem using ionic v5 and found 2 solutions (using ionic-native or directly) to solve the problem.

  1. Use ionic-native and import & add LaunchNavigator to providers in your app.module.ts. Also import LaunchNavigator, LaunchNavigatorOptions in your component/page and add LaunchNavigator to constructor. Afterwards add the following code sample:

`

// Using launchNavigator with ionic-native
// https://github.com/ionic-team/ionic-native/issues/2682; https://ionicframework.com/docs/native/launch-navigator
// Find missing consts:
// Common: https://github.com/dpa99c/phonegap-launch-navigator/blob/master/www/common.js,
// For android: https://github.com/dpa99c/phonegap-launch-navigator/blob/master/www/android/launchnavigator.js,
// For ios: https://github.com/dpa99c/phonegap-launch-navigator/blob/master/www/ios/launchnavigator.js

// Define launch options
let options: LaunchNavigatorOptions = {
  //app:                LaunchNavigator.APPS.UBER
  app:                  "user_select", // LaunchNavigator.APP.USER_SELECT,
  destinationName:      "Johannes Kepler Universität Linz",
  //start:              "London, ON",
  //start:              [48.3375598, 14.3219233],
  startName:            "Aktuelle Position",
  transportMode:        "driving", // LaunchNavigator.TRANSPORT_MODE.DRIVING, // Or WALKING or BICYCLING or TRANSIT
  enableGeocoding:      true, // Android & ios only
  enableGeolocation:    true, // Windows only
  enableDebug:          true,
  //extras:             {"t": "k"},
  launchModeGoogleMaps: "turn-by-turn", // LaunchNavigator.LAUNCH_MODE.TURN_BY_TURN, // Android only (or MAPS or GEO (via geo: URI scheme))
  launchModeAppleMaps:  "uri_scheme", // LaunchNavigator.LAUNCH_MODE.URI_SCHEME, // ios only

  appSelection:         {
    dialogHeaderText:   "Wähle ein App für die Navigation: ",
    cancelButtonText:   "Beenden",
    callback:           (app) => {
      console.log("user selected app: " + app);
    },
    //androidTheme: actionsheet.ANDROID_THEMES.THEME_HOLO_LIGHT, // Android only
    rememberChoice: {
      enabled:          "prompt", // Or true or false
      //promptFn: () => { ... Custom ui for asking the user },
      prompt:  {
        headerText:     "App-Auswahl merken?",
        bodyText:       "Immer die selbe App für die Navigation nutzen?",
        yesButtonText:  "Ja",
        noButtonText:   "Nein"
      }
    }
  },
};

// Navigate with app
this.launchNavigator.navigate([48.3375598, 14.3219233], options)
  .then(
    success => console.log('Launched navigator'),
    error => console.log('Error launching navigator', error)
  );

`

  1. Use launchnavigator directly and add declare let launchnavigator: any; (, after imports) to your component/page to prevent TypeScript errors. Afterwards use launchnavigator, like descirbed in the github docs and add the following sample code:

`

// Using launchNavigator directly (with 'declare let launchnavigator: any;')
// https://github.com/dpa99c/phonegap-launch-navigator
// Example: https://github.com/dpa99c/phonegap-launch-navigator-example

// Clears the current user choice of preferred navigator app
/*
launchnavigator.appSelection.userChoice.clear(() => {
  console.log("User's preferred app is cleared");
});
*/

// List apps available on the current device
/*
launchnavigator.availableApps((results) => {
  console.log("Show available navigation apps:");
  for(let app in results){
    //console.log(launchnavigator.getAppDisplayName(app) + (results[app] ? " is" : " is NOT ") +" available");
    if(results[app]) { console.log(launchnavigator.getAppDisplayName(app)); }
  }
});
*/

// Navigate with app
launchnavigator.navigate([48.3375598, 14.3219233], {
  //app:                launchnavigator.APPS.UBER
  app:                  launchnavigator.APP.USER_SELECT,
  destinationName:      "Johannes Kepler Universität Linz",
  //start:              "London, ON",
  //start:              [48.3375598, 14.3219233],
  startName:            "Aktuelle Position",
  transportMode:        launchnavigator.TRANSPORT_MODE.DRIVING, // Or WALKING or BICYCLING or TRANSIT
  enableGeocoding:      true, // Android & ios only
  enableGeolocation:    true, // Windows only
  enableDebug:          true,
  //extras: {"t": "k"},
  launchModeGoogleMaps: launchnavigator.LAUNCH_MODE.TURN_BY_TURN, // Android only (or MAPS or GEO (via geo: URI scheme))
  launchModeAppleMaps:  launchnavigator.LAUNCH_MODE.URI_SCHEME, // ios only

  appSelection:         {
    dialogHeaderText:   "Wähle ein App für die Navigation: ",
    cancelButtonText:   "Beenden",
    /*
    list: [
        launchnavigator.APP.GOOGLE_MAPS,  // Android & ios
        launchnavigator.APP.WAZE,  // Android & ios
        launchnavigator.APP.CITYMAPPER,  // Android & ios
        launchnavigator.APP.UBER,  // Android & ios
        launchnavigator.APP.APPLE_MAPS,  // ios
        launchnavigator.APP.NAVIGON,  // ios
        launchnavigator.APP.TRANSIT_APP,  // ios
        launchnavigator.APP.YANDEX,  // Android & ios
        launchnavigator.APP.TOMTOM,  // ios
        launchnavigator.APP.BING_MAPS,  // Windows
        launchnavigator.APP.SYGIC,  // Android & ios
        launchnavigator.APP.HERE_MAPS,  // Android & ios
        launchnavigator.APP.MOOVIT,  // Android & ios
        launchnavigator.APP.LYFT,  // Android & ios
        launchnavigator.APP.MAPS_ME  // Android & ios
    ],
    */
    callback:           (app) => {
      console.log("user selected app: " + app);
    },
    //androidTheme: actionsheet.ANDROID_THEMES.THEME_HOLO_LIGHT, // Android only
    rememberChoice: {
      enabled: "prompt", // Or true or false
      //promptFn: () => { ... Custom ui for asking the user },
      prompt:  {
        headerText:    "App-Auswahl merken?",
        bodyText:      "Immer die selbe App für die Navigation nutzen?",
        yesButtonText: "Ja",
        noButtonText:  "Nein"
      }
    }
  },

  successCallback: () => {
    console.log("launched navigator app");
  },
  errorCallback: (err) => {
    console.log("ERROR: launching navigator app: " + err);
  },
});

`

github-actions[bot] commented 2 years ago

There has been no recent activity and this issue has been marked inactive.