Quantcast
Channel: Ionic Forum - Latest topics
Viewing all 71023 articles
Browse latest View live

How to know if the user is turning to the left or right?

$
0
0

@Kyrax80 wrote:

I am using the following plugin, I am trying to know if the user is turning to the left or to the right. I know that if it’s to the right the angle is increasing and if it’s to the left the angle is decreasing. For this I am keeping a variable with the last angle that I got before the new one and compare if it’s smaller of bigger.

However, the problem comes if a user is turning in a place where the angle will be resetted (go from 360 to 0 or viceversa)

How could I detect if the user going to the left or right all the time without stop?

Thanks.

Posts: 1

Participants: 1

Read full topic


This page can't load google maps correctly error

$
0
0

@sahanpasindu wrote:

Hello…!

I am getting error like “This page can’t load google maps correctly” in my once page in my project. 1st of all i show my console details,
I have activated my project on console and i have correctly copy past my code from the console

I past script code to my index.html file like this

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="UTF-8">
  <title>Ionic App</title>
  <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">

  <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
  <link rel="manifest" href="manifest.json">
  <meta name="theme-color" content="#4e8ef7">

  <!-- add to homescreen for ios -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <!-- cordova.js required for cordova apps (remove if not needed) -->
  <script src="cordova.js"></script>

  <!-- un-comment this code to enable service worker
  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.error('Error', err));
    }
  </script>-->

  <link href="build/main.css" rel="stylesheet">

</head>
<body>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBa6gYiA16ORJpAm3Q-eXt6######"></script> <!-- hide my last few codes :D -->
</body>
</html>

And this is my control ts file.

import {Component, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';

/**
 * Generated class for the ContactPage page.
 */

@IonicPage()
@Component({
    selector: 'page-contact',
    templateUrl: 'contact.html',
})
export class ContactPage {
    @ViewChild("map") mapElement;
    map : any;

    constructor(public navCtrl: NavController, public navParams: NavParams) {
    }
    ngOnInit() {
        console.log('ionViewDidLoad ContactPage');
        this.initMap();
    }
    initMap(){
        let cords = new google.maps.LatLng(6.123166174,81.120666184);
        let mapOpt : google.maps.MapOptions = {
            center : cords,
            zoom : 12,
            mapTypeId : google.maps.MapTypeId.ROADMAP
        };

        this.map = new google.maps.Map(this.mapElement.nativeElement,mapOpt);
       let marker : google.maps.Marker = new google.maps.Marker({
            map: this.map, position: cords})
    }

}

Those are the my target lang and lat coordinates 6.123166174 81.120666184

And this is my view html codes

<!--
  Generated template for the ContactPage page.
-->
<ion-header>
    <ion-navbar>
        <ion-title>Contact Us</ion-title>
    </ion-navbar>
</ion-header>

<ion-content padding>
    <div #map id="map" class="google-map"></div>
</ion-content>

Terminal show me those error

[app-scripts] ‘marker’ is declared but its value is never read.
[app-scripts] L31: this.map = new google.maps.Map(this.mapElement.nativeElement,mapOpt);
[app-scripts] L32: let marker : google.maps.Marker = new google.maps.Marker({
[app-scripts] L33: map: this.map, position: cords})

Browser console show me this error

You have exceeded your request quota for this API. See https://developers.google.com/maps/documentation/javascript/error-messages?utm_source=maps_js&utm_medium=degraded&utm_campaign=billing#api-key-and-billing-errors
_.Yb @ js?key=AIzaSyBa6gYiA16ORJpAm3Q-eXt6iq#######:40

According to console error, That mean i have to pay use this service? isn’t free service :open_mouth:
Please somebody help me solve this issue :neutral_face:

Posts: 1

Participants: 1

Read full topic

Ionic v4 - ion-slide not working propperly (infinite horizontal scroll)

$
0
0

@Adrian_AGM wrote:

Ion-slide is not working propperly, it is working like an infinite horizontal scroll. Any additional property like pager or properties inside options are ignored.

I’ve realized that, when resizing screen (browser), ion-slide updates and works fine (see example gif below). On device, ion-slide also updates when changing device orientation.

Ionic info:

Ionic:

   ionic (Ionic CLI)          : 4.1.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.7
   @angular-devkit/core       : 0.7.5
   @angular-devkit/schematics : 0.7.5
   @angular/cli               : 6.1.5
   @ionic/ng-toolkit          : 1.0.8
   @ionic/schematics-angular  : 1.0.6

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : none
   Cordova Plugins       : no whitelisted plugins (0 plugins total)

System:

   NodeJS : v8.11.3 (/usr/local/bin/node)
   npm    : 5.6.0
   OS     : macOS High Sierra
   Xcode  : Xcode 9.4.1 Build version 9F2000

Steps to reproduce:

  1. Create new project:
    ionic start slides-demo tabs --type=angular
  2. Add simple ion-slides in HomePage:
<ion-slides pager="true">
  <ion-slide>
    Hi
  </ion-slide>
  <ion-slide>
    Hey
  </ion-slide>
</ion-slides>
  1. Run it on browser or device.

Posts: 1

Participants: 1

Read full topic

Intermittent white screen on iOS

$
0
0

@sentian wrote:

Hi there,

Not sure if anyone else has experienced this issue:

One of our clients is using our app on 2 different iPhones - SE and 6S. Every so often they get a white screen when starting up the app (splash screen displays then white screen of death). Client has tested on LTE and on home wifi with similar results.

We have tested this particular build extensively and we haven’t experienced this issue and neither have other clients.

Anybody seen anything like this before?

ionic v1 app built using Ionic Pro.

Thanks

Peter

Posts: 1

Participants: 1

Read full topic

Front camera Does not work

$
0
0

@joker84a wrote:

Hi I’m new with Ionic.
I’m trying to get a photo from front camera, but I read that any value to camera direction is not working because it alway will open back camera. I’have tried all solutions I have found but still it does not work.

Is there any other way to fix this problem ?
Thanks.

Posts: 1

Participants: 1

Read full topic

Using ion-menu on subrouting module

$
0
0

@nathantaal wrote:

Hello everyone,

I followed the Ionic 4 login tutorial from devtactics but implemented it on an existing app with a sidemenu.
As in the tutorial, the user get routed to a public or private page according to it’s login status. But now I’m having the problem that routing from within the sidemenu is not working anymore. The private folder has it’s own routing module file, and I can specify all pages in that module. The dashboard cannot be acces from the side menu.

This is how app.component.ts looks like (Its in src/app)

import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AuthenticationService } from './services/authentication.service';
import { Router } from '@angular/router';

@Component({
    selector: 'app-root',
    templateUrl: 'app.component.html'
})
export class AppComponent {
    // This is what's showing in hamburger menu
    public appPages = [
        {
            title: 'Dashboard',
            url: '/dashboard',
        },
    ];

    constructor(
        private platform: Platform,
        private splashScreen: SplashScreen,
        private statusBar: StatusBar,
        private authenticationService: AuthenticationService,
        private router: Router
    ) {
        this.initializeApp();
    }

    initializeApp() {
        this.platform.ready().then(() => {
            this.statusBar.styleDefault();
            this.splashScreen.hide();

            this.authenticationService.authenticationState.subscribe(state => {
                if (state) {
                    this.router.navigate(['bg', 'dashboard']);
                } else {
                    this.router.navigate(['login']);
                }
            });
        });
    }
}

As I think of it, one of the following thing could be a solution:

  1. change the ‘url’ in app.component to match the bg/dashboard route
  2. create a custom app.component inside the bg folder
  3. create a custom directive that has the routes for pages in the bg folder.

But I don’t understand how to implement any of these options. messing with any url breaks the auto forwarding in dashboard, I don’t know how to switch to a different app.component (and If that’s even possible) and the directive is not really a directive that I can change.
Any help would be appreciated!

Posts: 1

Participants: 1

Read full topic

Ionic 4 Vue JS tabs

$
0
0

@sts-ryan-holton wrote:

Hi, I’m trying to get the Tabs component to work in Vue JS. I’m having difficuilty in getting the click to work to take me to another page. I’ve followed the documentation https://beta.ionicframework.com/docs/api/tab on tabs and have attached a href to the <ion-tab> element, the href is showing when I inspect the element by it’s not taking me to that page. This is a snippet of my code:

            <ion-tabs>
              <ion-tab label="schedule" icon="calendar" name="tab-schedule" href="#/tenants/dashboard">
                <ion-nav></ion-nav>
              </ion-tab>
              <ion-tab label="speakers" icon="contacts" name="tab-speaker">
                <ion-nav></ion-nav>
              </ion-tab>
              <ion-tab label="map" icon="map" component="page-map"></ion-tab>
              <ion-tab label="about" icon="information-circle" component="page-about"></ion-tab>
            </ion-tabs>

I’ve tried the href with and without a hashtag, and with/without a forward slash.

Any ideas?

Posts: 1

Participants: 1

Read full topic

Ionic cordova build error- @app/scripts , metadata version mismatch versions 3 and 4

$
0
0

@JHammond21 wrote:

When i run the following command it compiles and builds, however when testing this on my device it doesnt install, the reason i believe is to do with the ‘ionic’ keyword that i did not include into the command.

 $cordova build android --prod --release 

when i run the following command, i get the error message attached at the bottom of this question, it says that my app-scripts caused an error.

$ionic cordova build android --emulate --prod --release

i have tried to run npm install and editing the versions of ionic within package.json however the troubleshooting hasnt helped much.

below is my package.json and versions.

{
“name”: “sqlite”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
@angular/common”: “4.4.3”,
@angular/compiler”: “4.4.3”,
@angular/compiler-cli”: “4.4.3”,
@angular/core”: “4.4.3”,
@angular/forms”: “4.4.3”,
@angular/http”: “4.4.3”,
@angular/platform-browser”: “4.4.3”,
@angular/platform-browser-dynamic”: “4.4.3”,
@ionic-native/core”: “4.12.2”,
@ionic-native/splash-screen”: “4.3.2”,
@ionic-native/sqlite”: “4.12.2”,
@ionic-native/status-bar”: “4.3.2”,
@ionic/app-scripts”: “^3.2.0”,
@ionic/storage”: “2.0.1”,
“cordova-android”: “6.3.0”,
“cordova-plugin-device”: “^1.1.7”,
“cordova-plugin-ionic-webview”: “^1.2.1”,
“cordova-plugin-splashscreen”: “^4.1.0”,
“cordova-plugin-statusbar”: “^2.4.2”,
“cordova-plugin-whitelist”: “^1.3.3”,
“cordova-sqlite-storage”: “^2.4.0”,
“ionic-angular”: “3.7.1”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“moment”: “^2.22.2”,
“rxjs”: “5.4.3”,
“sw-toolbox”: “3.6.0”,
“zone.js”: “0.8.18”
},
“devDependencies”: {
“typescript”: “2.3.4”
},
“description”: “An Ionic project”,
“cordova”: {
“plugins”: {
“cordova-sqlite-storage”: {},
“ionic-plugin-keyboard”: {},
“cordova-plugin-whitelist”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-ionic-webview”: {},
“cordova-plugin-statusbar”: {}
},
“platforms”: [
“android”
]
}
}

ionic info

error message

Posts: 1

Participants: 1

Read full topic


Reading file from system storage and displaying it in canvas with pdfjs

$
0
0

@filemonczyk wrote:

Im trying to read file stored in file system (android) and then put the content into canvas using pdfjs library so I could render it in view. Idid the same with system pdf viewer and it worked, but I need to do later some painting on it and manupulation so it can’t be dispsplayed in viewer, it must be within my app.

Rendering of my pdf works fine, since I have tested it with live reload mode.

Below is reading code

readFile( pathToFile ){
    this.file.resolveLocalFilesystemUrl( pathToFile).then((fileEntry: any) => {
      fileEntry.file( (file) => {
        var reader = new FileReader();
        reader.onloadend =  (event) => {
          const x = event.target as any;
          // let sliced = x._result.slice(x._result.indexOf(',') + 1, x._result.length);
          console.log('item', x)
          console.log('item', x.result)
          console.log('buffer',new Uint8Array(x.result))
          // console.log('64', new Uint8Array(x._result));
          // const bytes = this.base64ToUint8Array(sliced)
          this.renderPDF(x.result, this.container.nativeElement, 1)
        };
        reader.readAsArrayBuffer(file);
      });
    });
  }

as you can see pdf1 ist the last log so the promise from getDocument gets not resolved:

renderPDF(url, canvasContainer, scale) {
    console.log('pdf1')
    this.pdfCreator.disableWorker = true;
    this.pdfCreator
      .getDocument(url)
      .then((doc) => {
        this.doc = doc;
        console.log('pdf2')

        this.renderPages(canvasContainer, scale);
      })
      .catch(err => console.log(err))
  }

Posts: 1

Participants: 1

Read full topic

Android Native Back Button Not Like DevApp or Ionic View

$
0
0

@amzDeveloper wrote:

Hi!
I have some trouble deploying my app on a real android device.
I have tested my Ionic app in both Ionic DevAPP and Ionic View and all is working good with them.
When I install the generated APK in my Android device (same of DevApp and View) the native back button return back to the previous browser hoistory page and not do stuffs such as closes menus, dialogs and pages, or navigateing correctly to the app. What have I missed?

Thanks Gabor.

Posts: 1

Participants: 1

Read full topic

Click event doesn't work when Keyboard is open

$
0
0

@P-siu16 wrote:

I have a modalpage with 2 inputs one is for clients question and the other for the email, but when i finished typing and click the send button it just disilluminate the input and i have to click a second time for making the button sendPreformatted text the the question, any idea what can i do? Because i found no answer on github…

HTML:
  <div class="center">
    <ion-list>
      <ion-item no-lines>
        <h1 ion-item text-center style="color: #8054e7;">Envío de Consulta</h1>
      </ion-item>
      <ion-item>
        <ion-textarea class="consulta" name="comentario" #pregunta placeholder="Consulta"></ion-textarea>
      </ion-item>
      <ion-item>
        <ion-input class="correo" type="email" #email placeholder="Correo" blur="false"></ion-input>
      </ion-item>

      <br>
      <button ion-button style="border-radius: 50px;display: block;
                                margin-top: 25px;margin-bottom: auto;
                                margin-right:auto; margin-left: auto;"
                outline (click)=datosTicket(email.value,pregunta.value)>
        Enviar Consulta
      </button>
    </ion-list>
  </div>
  <ion-fab center>
    <button ion-fab mini (click)="cerrar()" type="submit"><ion-icon name="close" small></ion-icon></button>
  </ion-fab>

PAGE.TS:
  addZero(i){
    if(i < 10){
      i = "0" + i;
    }
    return i;
  }

  datosTicket(email:string,pregunta:string){

     let now = new Date();
     let day = ("0" + now.getDate()).slice(-2);
     let month = ("0" + (now.getMonth() + 1)).slice(-2);
     let hour = this.addZero(now.getHours());
     let minute = this.addZero(now.getMinutes());
     let second = this.addZero(now.getSeconds());
     let today = now.getFullYear() + "-" + (month) + "-" + (day) + " " + (hour) + ":" + (minute) + ":" + (second);

    if(email != '' && pregunta != '' ){
        this.idusuario = localStorage.getItem('idusuario');
        this.nombre_usuario = localStorage.getItem('nombre_usuario');
        this.userData = {
          idusuario: this.idusuario,
          nombre_usuario: this.nombre_usuario,
          email: email,
          pregunta: pregunta,
          fecha: today
        };
        console.log(this.userData);
        this._tp.enviarTicket(this.userData, "XXXXXXXX").then((result) =>{
          this.datosResp = result;
          console.log(this.datosResp);

          if(this.datosResp[0]['respuesta'] == "Exito"){
              const toast = this.toastCtrl.create({
                message: 'Su consulta fue enviada!',
                duration: 2500
              });
              toast.present();
              this.navCtrl.pop();
          } else {
              const toast = this.toastCtrl.create({
                message: 'Fallo en el envío, intentelo nuevamente.',
                duration: 2500
              });
              toast.present();
          }

      });

      } else {
        const toast = this.toastCtrl.create({
          message: 'Debe completar ambos campos',
          duration: 2500
        });
        toast.present();
      }


  }

Posts: 1

Participants: 1

Read full topic

Fab Buttons

Push Notifications with OneSignal not showing in device

$
0
0

@tecnosotros wrote:

I hope you are having a great day.

Note: I’m using Ionic 3 for my app.

So I’m stucked with OneSignal’s Push Notifications, last week my Push Notifications stopped working in some devices (I don’t see a pattern, sometimes it does not work in Android, sometimes in iOS).

This is the piece of code in Ionic where I catch the Push Notifications:

this.oneSignal.startInit(AppConstants.ApplicationId, AppConstants.GoogleProjectId);
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);

this.oneSignal.handleNotificationOpened().subscribe(data => {

    const type = data.notification.payload.additionalData.type.toUpperCase();

    switch (type) {
        case 'TYPE_1':
            // Do something
            break;
        case 'TYPE_2':
            // Do something else
            break;
        case 'TYPE_3':
            // Do something else
        break;
        default:
            console.log('Notification type not registered');
            break;
    }
});

this.oneSignal.endInit();

I call that code on the application start.

Every time my users send a Message (it is a feature in the app) I send a request to my REST Service and it sends a request to OneSignal (to their REST API)

The data I post to OneSignal’s REST API is:

{
    "app_id": "MY_PRIVATE_APP_ID",
    "ios_badgeType": "Increase",
    "ios_badgeCount": 1,
    "include_player_ids": [
        "141b5113-b8a4-4290-b1f7-cca75d3e9760",
        "141b6222-b844-3142-b463-ca1359914ff9",
        "24349992-c934-2941-c249-ffa514925284",
        "43242432-3234-2342-c534-aacb25492590",
    ],
    "priority": 10,
    "android_channel_id": "26ca5296-f10f-4294-a3c6-942b1b88141b",
    "headings": {
        "en": "You have a message",
        "es": "Tienes un mensaje"
    },
    "contents": {
        "en": "Rick Sanchez sent you a message",
        "es": "Rick Sanches te envió un mensaje"
    },
    "data": {
        "type": "TYPE_1"
    }
}

So far, not all recipients received the Push Notification (In that specific example I’m using an iPad with iOS 11, iPhone 7 with iOS 11, Samsung Galaxy S7 with Android 7 and a Motorola G5 with Android 7), I just received in one of them (the iPhone 7), but if I repeat the test then I can get the Push Notification with the Galaxy S7, or even 2, 3 or the 4 devices.

Then if I check the Delivery status in OneSignal dashboard I see that the Push Notification was correctly delivered to all the recipients (so far so good), but not all showed the PN.

Note: my devices are not in a battery saving mode

Posts: 1

Participants: 1

Read full topic

CSS4 ion-button height. How to change?

$
0
0

@wterrill wrote:

I’m upgrading a functioning app from v3 to v4.

I’ve been trying to change the height of the components to no avail. I suspect what I need to do is add a CSS4 variable in the variables.scss file for the particular page I’m targeting, such as:

app-name-of-specific-page{
–ion-button-height: 100px;
}

but that doesn’t seem to work, specifically because I can’t find the default height variable. (–ion-button-height is a shot in the dark. I can’t find any documentation on that)

I see in the html itself that the button height is controlled by a the .button-native class… but I can’t seem to override it in the app-name-of-specific.page.scss file (even with !important.) However, if I change the default value for height in the browser [it defaults to var(–height);] It has an effect.

Here are some screenshots from the browser:
I’d like to make the below buttons taller


the HTML

the CSS properties of the button class

Posts: 1

Participants: 1

Read full topic

Problem Downloading Insecure Images On iOS

$
0
0

@dalezak wrote:

I ran into a problem downloading insecure http:// images on iOS using the HTTP plugin. The downloadFile request fails with the error There was an error downloading the file.

I suspect it’s related to iOS restrictions on insecure content, so think setting setSSLCertMode to nocheck would help.

However whenever I try calling setSSLCertMode I get the warning Ionic Native: tried calling HTTP.setSSLCertMode, but the HTTP plugin is not installed in the console.

Ionic Native: tried calling HTTP.setSSLCertMode, but the HTTP plugin is not installed.
Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'

The plugin is installed though, since I can remove the setSSLCertMode call and HTTP requests work fine.

Unfortunately some of our images are hosted on Rackspace on http:// and haven’t been migrated to https://, so I’m stuck trying to load these insecure images.

Any thoughts or suggestions?

Posts: 2

Participants: 1

Read full topic


Natives Plugs Inns in Ionic 4

$
0
0

@Motero69 wrote:

Anyone can help, I’m trying to use some plugs inns in Ionic 4 but doesn’t work, I try with Camera, Facebook, Google and more but doesn’t work, I follow the Ionic Documentation and apparently everything is correct but when I run the App show an error and not show anything.

I realize that only when I import the plugins in the app.module.ts is when fail, and I try many Native PlugInns and all don’t work. when I take off the Imports in app.modules.ts the App work again (of course without the plugins)

Posts: 2

Participants: 2

Read full topic

Ion-tab and Angular Routing Multi Tenancy Ionic 4

$
0
0

@joaquim3541 wrote:

Hello,

I’m trying use ion-tab togheter with multi-tenancy defined in my WebApp.

The code:

tabs.router.module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { TabsPage } from './tabs.page';
import { HomePage } from '../home/home.page';

const routes: Routes = [
  {
    path: ':tenant',
    children: [
      {
        path: 'tabs',
        component: TabsPage,
        children: [
          {
            path: '',
            redirectTo: '/tabs/(home:home)',
            pathMatch: 'full',
          },
          {
            path: 'home',
            outlet: 'home',
            component: HomePage
          }      
        ]
      }      
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class TabsPageRoutingModule {}

app.routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginPage } from './login/login.page';
import { TabsPage } from './tabs/tabs.page';

const routes: Routes = [
  {
    path: ':tenant',
    children: [
      { path: '', component: LoginPage },
      { path: 'login', component: LoginPage },
      { path: 'tabs', component: TabsPage }      
    ]
  }
];
@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

app.component.ts

import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { Router, NavigationStart } from '@angular/router';
import { AppSettings } from '../../AppSettings';

const addPath = (urlAndQuery: string[]) => urlAndQuery[0] ? '/' + urlAndQuery[0] : '';
const addQuery = (urlAndQuery: string[]) => urlAndQuery[1] ? '?' + urlAndQuery[1] : '';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html'
})
export class AppComponent {

  private activeTenant: string;

  constructor(
    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
    private router: Router
  ) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });

    const tenants = ['colsimbios', 'visao'];
    const defaultTenant = AppSettings.dominio;
    
    this.router.events.subscribe((event: any) => {

      if(!(event instanceof NavigationStart)) return;
      
debugger;

      const url = event.url === '/' ? '' : event.url;
      const urlAndQuery = url.split('?');
      const pathMap = urlAndQuery[0].split('/');
      const firstPathPart = pathMap[1];
      if (tenants.includes(firstPathPart) || firstPathPart === defaultTenant) {
        if (firstPathPart !== this.activeTenant) {
          this.activeTenant = firstPathPart;
        }

      } else {
        let prefix;
        if (this.activeTenant) {
          prefix = this.activeTenant;
        } else {
          prefix = defaultTenant;
        }
        const redirectUrl = '/' + prefix + addPath(urlAndQuery) + addQuery(urlAndQuery);

        console.log(this.router.config);
        this.router.navigate([redirectUrl]);        
      } 
      
    });
  }
}

tabs.html

<ion-tabs #myTabs *ngIf="carregouOsDados">
          <ion-tab *ngIf="perfil.Tipo" icon="home" label="Notícias"  href="tabs/(home:home)">
            <ion-router-outlet name="home"></ion-router-outlet>           
          </ion-tab>
</ion-tabs>

The error:

Anyone already try it?

Posts: 1

Participants: 1

Read full topic

Ionic 4 - Is now a good time to migrate?

$
0
0

@karvanj wrote:

I have been working on a V3 application which is to be released early next year. I am at a cross roads whether to migrate to v4 now which if I do would mean less work in the long run.

I have been religiously following the beta updates of Ionic 4 which at this time of post is at beta 8. From what I see the bugs being fixed are not major flaws but just minor nuances.

So my question to the devs on the beta is the system stable enough to warrant me to start the migration from v3 to v4? Also how far away do people think we are for the beta to be finished and the official release?

Many thanks in advance.

Posts: 2

Participants: 2

Read full topic

Can I work on an ionic 3 project after upgrading to ionic 4?

$
0
0

@5odin wrote:

I’ve upgraded to ionic 4 to try it and learn what’s new. Meanwhile I still want to work on my ionic 3 projects. is it possible?

Posts: 1

Participants: 1

Read full topic

When is Ionic 4 out of beta?

$
0
0

@mbusby wrote:

When will Ionic 4 be out of beta? We have some templates and plugins that we would like to put on the Ionic market.

Posts: 3

Participants: 2

Read full topic

Viewing all 71023 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>