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

Issue when navigating on same component

$
0
0

Hello,
i’m facing an issue (possible bug?) when navigating between routes that renders the same component.
I have a list of categories (parent-> children) that i want to navigate

          <Route path="/:tab(categories)" component={Tab1} exact={true} />
          <Route path="/:tab(categories)/:categoryId" component={Tab1} exact={true} />

the effect is that when navigating to /:tab(categories)/:categoryId it pushes the new view but reuses the older component so i can clearly see the same data on the screen.

Is there a way to instatiate a new component (same one, new instance) instead of reuse the older one?

1 post - 1 participant

Read full topic


Ionic Not Working with ReactiveForms

$
0
0

Guys there is something wrong with the latest version of Ionic. I cannot get ReactForms to work at all. I’m pretty sure I’m not messing this up.

Here is an example:

component.ts

import { Component, OnInit } from '@angular/core';
import { AngularEditorConfig } from '@kolkov/angular-editor';
import { JournalService } from '../services/journal.service';
import { AlertController, LoadingController } from '@ionic/angular';
import { FormGroup, FormControl } from '@angular/forms';

@Component({
  selector: 'app-tab2',
  templateUrl: 'tab2.page.html',
  styleUrls: ['tab2.page.scss']
})
export class Tab2Page implements OnInit {

  editorConfig: AngularEditorConfig = {
    editable: true,
    spellcheck: true,
    height: 'auto',
    minHeight: '0',
    maxHeight: 'auto',
    width: 'auto',
    minWidth: '0',
    translate: 'yes',
    enableToolbar: true,
    showToolbar: true,
    placeholder: 'What happened during your Bible reading today?',
    defaultParagraphSeparator: '',
    defaultFontName: '',
    defaultFontSize: '',
    fonts: [
      { class: 'arial', name: 'Arial' },
      { class: 'times-new-roman', name: 'Times New Roman' },
      { class: 'calibri', name: 'Calibri' },
      { class: 'comic-sans-ms', name: 'Comic Sans MS' }
    ],
    customClasses: [
      {
        name: 'quote',
        class: 'quote',
      },
      {
        name: 'redText',
        class: 'redText'
      },
      {
        name: 'titleText',
        class: 'titleText',
        tag: 'h1',
      },
    ],
    uploadUrl: 'v1/image',
    uploadWithCredentials: false,
    sanitize: true,
    toolbarPosition: 'top',
    toolbarHiddenButtons: [
      ['undo', 'redo', 'strikeThrough', 'subscript', 'superscript', 'heading', 'fontName'],
      ['fontSize', 'customClasses', 'link', 'unlink', 'insertHorizontalRule', 'removeFormat'],
      ['insertImage', 'insertVideo', 'toggleEditorMode']
    ]
  };
  entryForm: FormGroup;

  constructor(private journalService: JournalService,
              private alertCtrl: AlertController,
              private loaderCtrl: LoadingController) { }

  async ngOnInit() {
    await this.showLoader();
    this.initForm();
    this.loaderCtrl.dismiss();
  }

  initForm() {
    this.entryForm = new FormGroup({
      title: new FormControl(''),
      entry: new FormControl('')
    });
  }

  async showLoader() {
    const l = await this.loaderCtrl.create({
      spinner: 'dots'
    });
    return l.present();
  }

  async createAlert(mess: string, isError: boolean) {
    const a = await this.alertCtrl.create({
      message: mess,
      buttons: [isError ? 'Try Again' : 'OK']
    });
    await a.present();
  }

  onCreateEntry() {
    this.showLoader();
    const journalObject = {
      ...this.entryForm.value
    };
    this.journalService.newJournalEntry(journalObject)
      .then(data => {
        console.log(data);
        console.log('Data stored.');
      })
      .catch((err) => {
        this.createAlert(err, true);
      })
      .finally(() => this.loaderCtrl.dismiss())
  }
}

component.module

import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Tab2Page } from './tab2.page';

import { AngularEditorModule } from '@kolkov/angular-editor';

@NgModule({
  imports: [
    IonicModule,
    CommonModule,
    FormsModule,
    RouterModule.forChild([
      { path: '', component: Tab2Page, pathMatch: 'full' }
    ]),
    AngularEditorModule,
    ReactiveFormsModule,
    FormsModule
  ],
  declarations: [
    Tab2Page
  ]
})
export class Tab2PageModule {}

component.html

<ion-header>
  <ion-toolbar color="primary">
    <ion-title *ngIf="entryForm.get('title').value !== undefined">{{ entryForm.get('title').value }}</ion-title>
    <ion-title *ngIf="!entryForm.get('title').value">New Entry</ion-title>
    <ion-buttons slot="end">
      <ion-button color="secondary">SAVE</ion-button>
    </ion-buttons>
  </ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
  <ion-header collapse="condense" color="primary">
    <ion-toolbar color="primary">
      <ion-title size="large" color="secondary" *ngIf="entryForm.get('title').value !== undefined">{{ entryForm.get('title').value }}</ion-title>
      <ion-title size="large" color="secondary" *ngIf="!entryForm.get('title').value">New Entry</ion-title>
    </ion-toolbar>
  </ion-header>
  <div [formGroup]="entryForm">
    <ion-item lines="none">
      <ion-input placeholder="Title" formControlName="title"></ion-input>
    </ion-item>
    <angular-editor formControlName="entry" [config]="editorConfig"></angular-editor>
  </div>

</ion-content>

Here is the Ionic Info

Ionic:

   Ionic CLI                     : 6.10.0 (/Users/wd/.nvm/versions/node/v12.11.1/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.1.1
   @angular-devkit/build-angular : 0.901.7
   @angular-devkit/schematics    : 9.1.7
   @angular/cli                  : 9.1.7
   @ionic/angular-toolkit        : 2.2.0

Capacitor:

   Capacitor CLI   : 2.1.2
   @capacitor/core : 2.1.2

Utility:

   cordova-res (update available: 0.14.0) : 0.8.1
   native-run (update available: 1.0.0)   : 0.3.0

System:

   NodeJS : v12.11.1 (/Users/wd/.nvm/versions/node/v12.11.1/bin/node)
   npm    : 6.14.5
   OS     : macOS Catalina

2 posts - 2 participants

Read full topic

Core.js:6228 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'menu/home' Error: Cannot match any routes. URL Segment: 'menu/home' at ApplyRedirects.noMatchError (router.js:4396)

$
0
0

I’m having an issue when i click an item on my side menu errors appeared on the console

menu.module.ts

import { NgModule } from ‘@angular/core’;
import { CommonModule } from ‘@angular/common’;
import { FormsModule } from ‘@angular/forms’;
import { Routes, RouterModule } from ‘@angular/router’;

import { IonicModule } from ‘@ionic/angular’;

import { MenuPageRoutingModule } from ‘./menu-routing.module’;

import { MenuPage } from ‘./menu.page’;

const routes: Routes = [
{
path: ‘menu’,
component: MenuPage,
children : [
{
path: ‘home’,
loadChildren: () => import(’…/home/home.module’).then( m => m.HomePageModule)
},
{
path: ‘games’,
loadChildren: () => import(’…/games/games.module’).then( m => m.GamesPageModule)
},
{
path: ‘account’,
loadChildren: () => import(’…/account/account.module’).then( m => m.AccountPageModule)
},
{
path: ‘’,
redirectTo: ‘home’,
pathMatch: ‘full’
}

]

},
{
path: ‘’,
redirectTo:‘menu’,
pathMatch: ‘full’
}
];

@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
MenuPageRoutingModule
],
declarations: [MenuPage]
})
export class MenuPageModule {}


app-routing.module.ts

import { NgModule } from ‘@angular/core’;
import { PreloadAllModules, RouterModule, Routes } from ‘@angular/router’;

const routes: Routes = [
{
path: ‘’,
loadChildren: () => import(’./pages/menu/menu.module’).then( m => m.MenuPageModule)
}
];

@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }

1 post - 1 participant

Read full topic

IOnic3 Video call Integration

$
0
0

I want to integrate one to one video call feature to the Ionic3 project, it should support all platforms like WEB, Android, IOS. I tried so many APIs like VONAGE, PUBNUB-WebRtc, ZohoDesk, OPenTok,Enablex. But all libraries are supporting only mobile platforms through Ionic, those are not supporting on the web. Can anyone help to do this.
thankyou

1 post - 1 participant

Read full topic

What is this error and how do I solve it?

$
0
0

I ran cmd

ionic cordova run android --verbose

All went well but suddenly this error appeared :frowning:

Prepared android project successfully
No scripts found for hook “after_prepare”.
No scripts found for hook “before_compile”.

I have wasted two days on it. Any help or ideas are appreciated.
Thanks !

1 post - 1 participant

Read full topic

presentingElement with Vue

$
0
0

Has anyone successfully figured out which element to pass as presentingElement when calling modalController.create() in Vue? I’m trying to get the iOS 13 stacked modal behavior I see in the modal demo here.

I’ve tried the <ion-router-outlet> element, that didn’t work. I’m passing swipeToClose: true.

1 post - 1 participant

Read full topic

Capacitor App.getLaunchUrl() issue on Android device

$
0
0

Hello everyone I am trying to implement deep linking using capacitor methods like App.getLaunchUrl().
everything work fine when App is closed but when the App is opened in the background the App.getLaunchUrl() returns empty.
This is the versions which I am using:

 {
    "@capacitor/android": "^2.1.0",
    "@capacitor/core": "2.1.0",
    "@capacitor/ios": "^2.1.0",
    "@ionic-native/contacts": "^5.26.0",
    "@ionic-native/core": "^5.26.0",
    "@ionic-native/deeplinks": "^5.26.0",
    "@ionic/app-scripts": "3.2.4",
    "@ionic/pwa-elements": "^1.5.2",
    "@ionic/react": "^5.1.0",
    "@ionic/react-hooks": "0.0.8",
    "@ionic/react-router": "^5.1.0",
    "@testing-library/jest-dom": "^5.7.0",
    "@testing-library/react": "^10.0.4",
    "@testing-library/user-event": "^10.1.2",
    "@types/jest": "^25.2.1",
    "@types/lodash": "^4.14.153",
    "@types/node": "^13.13.5",
    "@types/react": "^16.9.35",
    "@types/react-dom": "^16.9.8",
    "@types/react-router": "^5.1.7",
    "@types/react-router-dom": "^5.1.5",
    "axios": "^0.19.2",
    "cordova-plugin-contacts": "^3.0.1",
    "ionic": "^5.4.16",
    "ionic-plugin-deeplinks": "^1.0.20",
    "ionicons": "^5.0.1",
    "lodash": "^4.17.15",
    "node-sass": "^4.14.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1",
    "short-unique-id": "^3.0.3",
    "typescript": "3.8.3"
  }

And this is the related code,

import React, { useReducer, useEffect, useState } from "react";
import { Route, Redirect } from "react-router-dom";
import { IonApp, IonRouterOutlet } from "@ionic/react";
import { IonReactRouter } from "@ionic/react-router";
import Home from "./pages/Home/Home";
import InroPage from "./pages/IntroPage/IntroPage";
import Login from "./pages/Login/Login";
import Verfication from "./pages/Verification/Verifocation";
import Profile from "./pages/Profile/Profile";
import HomePage from "./pages/HomePage/HomePage";
import CircleDetail from "./pages/CircleDetail/CircleDetail";
import InvitationPage from "./pages/InvitationPage/InvitationPage";
import Actions, { Context, initialState, reducer } from "./state/globalState";

/* Core CSS required for Ionic components to work properly */
import "@ionic/react/css/core.css";

/* Basic CSS for apps built with Ionic */
import "@ionic/react/css/normalize.css";
import "@ionic/react/css/structure.css";
import "@ionic/react/css/typography.css";

/* Optional CSS utils that can be commented out */
import "@ionic/react/css/padding.css";
import "@ionic/react/css/float-elements.css";
import "@ionic/react/css/text-alignment.css";
import "@ionic/react/css/text-transformation.css";
import "@ionic/react/css/flex-utils.css";
import "@ionic/react/css/display.css";
/* Theme variables */
import "./theme/variables.css";
import "./styles/main.scss";
import { Plugins } from "@capacitor/core";
const { Storage } = Plugins;
const { App: CapApp } = Plugins;
const App: React.FC = () => {
  // const history = useHistory();

  const [hasData, setHasData] = useState(false);
  const [URL, setURL]: any = useState(null);
  const [store, dispatch] = useReducer(reducer, initialState);
  const getObject = async () => {
    const ret: any = await Storage.get({ key: "userData" });
    const user = JSON.parse(ret.value);
    return new Promise((resolve, reject) => {
      resolve(user);
    });
  };

  Plugins.App.addListener("appUrlOpen", (data: any) => {
    console.log("from app URL in APP Component");
    console.log(data);
    const resultID = data.url.split("/")[data.url.split("/").length - 1];
    setURL("/circle/" + resultID);
  });
  Plugins.App.addListener("appStateChange", async (state: any) => {
    console.log("from app state change in APP Component", state);
    const a = await Plugins.App.getLaunchUrl().then((ret) => {
      console.log(ret);
      if (ret.url !== "") {
        const resultID = ret.url.split("/")[ret.url.split("/").length - 1];
        setURL("/circle/" + resultID);
      } else {
        setURL(null);
      }
    });
    setTimeout(() => {
      console.log("in the settime out", a);
    }, 2000);
  });
  useEffect(() => {
    getObject().then((data: any) => {
      // console.log(data);
      if (data !== null) {
        setHasData(true);
      }
      Plugins.App.getLaunchUrl().then((ret) => {
        // console.log(ret);
        if (ret.url !== "") {
          // console.log("outside of useEffect");
          // console.log(ret.url.split("/"));
          const resultID = ret.url.split("/")[ret.url.split("/").length - 1];

          setURL("/circle/" + resultID);
        } else {
          setURL(null);
        }
      });
      // console.log(ret);
    });
  }, []);
  return (
    <Context.Provider value={{ store, dispatch }}>
      <IonApp>
        <IonReactRouter>
          {/* <AppUrlListener></AppUrlListener> */}
          {URL !== null && <Redirect to={URL} />}
          <IonRouterOutlet>
            <Route path="/circle/:id" component={InvitationPage} exact />
            <Route exact path="/" component={hasData ? HomePage : InroPage} />
            <Route exact path="/home-page" component={HomePage} />
            <Route path="/login" component={Login} />
            <Route path="/circle-detail/:id" component={CircleDetail} exact />
            <Route path="/verification" component={Verfication} />
            <Route path="/profile" component={Profile} />
            <Route path="/home" component={Home} exact={true} />
          </IonRouterOutlet>
        </IonReactRouter>
      </IonApp>
    </Context.Provider>
  );
};

export default App;

Also as you see I have tried to get the launch URL when the App state is changing.
And I tried other different methods as you can see inside the code like appUrlOpen.

1 post - 1 participant

Read full topic

Ionic react Appflow live updates not working

$
0
0

Hi.
I am trying to use Appflow’s live updates, but it does not work.

my string.xmlis like following:

<?xml version='1.0' encoding='utf-8'?>
<resources>
...
  <string name="ionic_app_id">fbba1af6</string>
  <string name="ionic_channel_name">Master</string>
  <string name="ionic_update_method">auto</string>
  <string name="ionic_max_versions">0</string>
  <string name="ionic_min_background_duration">1000</string>
  <string name="ionic_update_api">auto</string>
</resources>

the log cat is like following:

I think the error comes from capacitor-runtime.js's parsing the JSON.

Any body help me?

Thanks.

1 post - 1 participant

Read full topic


[Ionic 5 - Angular] Recommended way to add dynamic elements to the DOM

$
0
0

What is the recommended way to add and remove dynamic elements to the DOM with Ionic and Angular? I was just injecting them with Javascript appendChild which did append the element to the DOM but i am not able to modify the element once appended (like add/remove a class to the element).

The elements are varied, so i can’t use just a *ngFor loop.

Usecase: Its a calling app wherein each time a new user joins, i create a div with different elements and a video element and append it to the DOM, then when different events happen like user toggling off his camera, i need to apply changes to the appended element.

Thanks.

1 post - 1 participant

Read full topic

Ionic chat app with firebase bakend

Opinions about migrating from v3 to v4

$
0
0

Hello,

2 years ago I created an app using Ionic 3 and now I’d love to update it to Ionic 4, my project uses lots of libraries and especially lots of Cordova plugins which, from my understanding, aren’t a thing anymore in Ionic 4.

I am worried the migration process is just too much for this project and I’m writing this post because I’d love to hear your opinion before starting to work on it. Is this migration doable given the following list of dependencies my project uses?

List of dependencies:

  "dependencies": {
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@ionic-native/base64": "^4.12.0",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/date-picker": "^4.12.0",
    "@ionic-native/file": "^4.12.0",
    "@ionic-native/file-opener": "^4.12.0",
    "@ionic-native/file-transfer": "^4.12.0",
    "@ionic-native/photo-viewer": "^4.12.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "^2.1.3",
    "com-badrit-base64": "^0.2.0",
    "com-sarriaroman-photoviewer": "^1.1.18",
    "cordova-android": "7.0.0",
    "cordova-browser": "5.0.4",
    "cordova-plugin-datepicker": "^0.9.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-save-image": "^0.3.0",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-wallpaper": "^0.1.1",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "^2.4.0",
    "ionic-angular": "3.9.2",
    "ionic-cache": "^3.1.2",
    "ionic-image-loader": "^5.0.5",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.8",
    "typescript": "2.4.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "com-sarriaroman-photoviewer": {},
      "cordova-plugin-datepicker": {},
      "cordova-plugin-file": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-save-image": {},
      "cordova-plugin-wallpaper": {},
      "com-badrit-base64": {}
    },

If needed or if someone is curious I can share the app source code as it’s opensource, here’s the Github repository.

And again. feel free to be brutally honest with me!

1 post - 1 participant

Read full topic

Ionic native audio not works in backgroundmode

$
0
0

playAudio(){
this.backgroundMode.enable();
this.backgroundMode.on(“activate”).subscribe(()=>{
// this.backgroundMode.disableWebViewOptimizations();
console.log(‘bg’)
this.audio.play(“audio1”);
});
this.audio.play(“audio1”);
}

}

pushObject.on(‘notification’).subscribe((notification: any) =>
{

this.audio.preload(‘audio1’, ‘assets/sound/gg.mp3’);

this.playAudio()

 console.log('Received a notification', notification);
 let noti: any = notification.additionalData.notify_id;
  if(notification.additionalData.notify_id){
    Swal.fire({
      title: 'Notification',
      text: 'New Qutation Received!',
      icon: 'warning',
      showCancelButton: true,
      confirmButtonText: 'View List',
      cancelButtonText: 'Ok'
    }).then((result) => {
      if (result.value) {
        let qutationList:any = '{"access_token":"'+this.accessToken+'","operation":"Update_notification","moduleType":"transactionapproval_quotation","api_type":"web","element_data":{"action":"Update_notification","userID":"'+this.userId+'","notify_id":"'+noti+'"}}';
        this.apiservice.sendServer(qutationList).then((response:any) => {
          console.log(response);
          this.nav.navigateRoot('/quotation');
        });
  
      }
    })
  }
});

pushObject.on(‘error’).subscribe(error => console.error(‘Error with Push plugin’, error));

}

  • I call this in background ,it not works*

1 post - 1 participant

Read full topic

Cannot use namespace as a type

Looking for PhoneGap Build alternative

$
0
0

I can build my (Bootstrap JQuery) app on PGB. But I need to find an alternative because of the iOS SDK 13 situation. With PGB I can:-
1 build for iOS and Android
2 build iOS without a Mac (except Transporter for submit (I use macincloud))
3 use a few cordova plugins

I thought the solution was AppFlow. But support has said this is not straightforward. still investigating.

I want to minimise code/config changes

so what are more options if appFlow is not suitable? I supect

  • get a Mac (or macincloud) and build locally
  • Capacitor (maybe)

If I build locally on a Mac do I need any Ionic at all or is Cordova enough?

Peter

1 post - 1 participant

Read full topic

Easy Steps To Recover Google Account

$
0
0

When you can’t access your Google account due to incorrect details, you need to recover it. As Google is security-driven, it provides you with different recovery options, using which you can easily and securely recover your password. To recover your Google account password, you can refer to this article- http://www.gmailsupportpedia.com/article/google-password-recovery

Recovery of Google account

If you want to want to know how to recover Google account , follow these steps:

  • On the recovery page, enter your Google account username and click Next.
  • Click Forgot password link on the next page to get the recovery options.
  • You can recover your account using any old password of your account. If not, proceed to the next.
  • Then, the recovery option of selecting the date when you created your Google account is there. You can skip it also.
  • After that, is the recovery phone number. You can enter the associated phone number in the given field.
  • Finally, you can use an alternate email address for recovery.
  • Once you are verified, you can create a new password.

For any help, contact Google support team @ 1-855-925-7081.

1 post - 1 participant

Read full topic


Responsive Routing

$
0
0

Hi,

I was hoping to get some clarification on how I can use Tabs on Mobile, but an alternative Navigation on Desktop. I’m familiar with responsive design, so this is not about hiding and showing elements, but rather routing.

The problem & a solution is given here: https://www.youtube.com/watch?v=FVwuCO5vJxI

And a somewhat related discussion by @brandyshea here: https://github.com/ionic-team/ionic/issues/14610#issuecomment-439132180

So it seems we have to resort to using an another for desktop (which in my testing doesnt seem to support relative routing of the child pages, even though the inbuilt Tabs router does).
And then we also have to deal with the fact the Tabs routing will break unless we reload the page.

My question is, is this really the best you can expect from using Ionic is a very typical scenario ?

Ultimately Ionic has been marketed as working on the desktop and on devices/mobile etc.
But this approach seems like a hack.
And the issue has been around for quite a while.

I dont want sounds too critical here, as I’m probably not aware of the underlying issues.
But it feels very frustrating as a user when given such a simple use case, we have to restort to hacks, and probably the type of thing that will suck far more maintenance time than it deserves.

Thanks for your time.

1 post - 1 participant

Read full topic

Using Capacitor with Nx Monorepo

$
0
0

I have been experimenting with using Capacitor in an Nx monorepo and I am close to getting things working well, but have just a couple of issues. First of all, I would like to have an app in my Nx workspace dedicated to Capacitor for another given app. Directory-wise, it looks like this:

apps/
  mobile-app/
  mobile-app-cap/

Due to the monorepo nature of Nx, I would like my capacitor.config.json to be located within mobile-app-cap/ so I could have multiple Capacitor apps in a given workspace. The problem is that when I try to do npx cap add from the root of the project then it doesn’t find my capacitor.config.json, and then I run that command from the mobile-app-cap/ folder it says that it cannot find the package.json and should be ran from the root.

That being said, the Ionic CLI has some multi-app support with the ionic.config.json (https://ionicframework.com/docs/cli/configuration#multi-app-projects) so it seems like Capacitor should be able to handle this structure.

Is there a parameter that can be passed into the capacitor commands that can specify the project directory where capacitor.config.json lives and where I want the native project folders to be generated? I ideally would like to run these commands from the root project directory without having to rely on the Ionic CLI.

Thanks in advance!

1 post - 1 participant

Read full topic

Prevent Angular resolver running on back button

$
0
0

Hi

How can I stop an Angular resolver running when clicking the ion-back-button?

I have two components; DashboardComponent and PageOneComponent. When the app first loads, the DashboardComponent resolver fires, fetches an array of data from the API and displays it on the DashboardComponent in a list of ion-item. Users can then click on an ion-item, which navigates to the PageOneComponent, to view more information about each item. When clicking ion-back-button, the User is taken back to the DashboardComponent and the resolver fires again.

As the Ionic DashboardComponent is never really destroyed, I wouldn’t expect the resolver to run again when clicking the back button. The same way as the ngOnInit event doesn’t fire when clicking the back button either.

Does anyone know how to prevent this behaviour?

1 post - 1 participant

Read full topic

Ionic 5 service singleton?

$
0
0

Hi,

In my ionic app, i have a service that has an instance of a websocket, in the constructor method, i create the socket and pass the reference to it to the pages that need it, Aren’t services supposed to be singleton? as i’m getting multiple instances of the sockets as i navigate between pages.

Also for this page i’ve set ViewEncapsulation to None if it makes any difference.

6 posts - 3 participants

Read full topic

CORS error with Angular HTTP and PHP

$
0
0

Hello, I have been stuck with this for days and I am sort of new in ionic… Any possible solution that might work is welcome.

------> So, I have been making HTTP calls using angular’s HTTPClient in my ionic app for android. The code -

// connection with server
  postData(body, file) {
    const type = 'application/json; charset=UTF-8';
    const httpOptions = {
        headers: new HttpHeaders({   'Content-Type': type  })
    };
    return this.http.post(this.server + file, body, httpOptions)
        .pipe(
            catchError(this.handleError)
        );

------> I have PHP for backend with these headers -

   header('Access-Control-Allow-Origin: *');
   header('Access-Control-Allow-Method: POST, GET, OPTIONS');
   header('Access-Control-Allow-Headers: Content-Type'); 
   header('Content-Type: text/html; charset=utf-8');
 
    $ReceivedData = json_decode(file_get_contents("php://input"), true);

------> Problem: The HTTP connection works perfectly in local server. But when I put the exact same PHP files on a live server. The preflight requests fail with the following error:

Access to XMLHttpRequest at ‘http://liveserveraddress/index.php’ from origin ‘http://localhost:8100’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

What am I doing wrong?

ionic info

Ionic:

   Ionic CLI                     : 5.4.16 (C:\Users\admin\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 5.1.1
   @angular-devkit/build-angular : 0.901.7
   @angular-devkit/schematics    : 9.1.7
   @angular/cli                  : 9.1.7
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 6 other plugins)

Utility:

   cordova-res : 0.14.0
   native-run  : 0.3.0

System:

   Android SDK Tools : 26.1.1 (C:\Users\admin\AppData\Local\Android\Sdk)
   NodeJS            : v10.16.1 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

1 post - 1 participant

Read full topic

Viewing all 70448 articles
Browse latest View live


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