Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all 49253 articles
Browse latest View live

Change view with onClick function

$
0
0

Dear

This is the main component of the application. As you can see in IonComponent there are two buttons and a component called NewAccountRegister, which I want to be hidden until a button is pressed. Then RegisterNewAccount should be shown and the buttons hidden

What is the best way to hide the buttons and show RegisterNewAccount component?

const Registro: React.FC = () => {
  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonTitle>CallServices</IonTitle>
        </IonToolbar>
      </IonHeader>
      <IonContent fullscreen>
        <IonHeader collapse="condense">
          <IonToolbar>
            <IonTitle size="large">Registro</IonTitle>
          </IonToolbar>
        </IonHeader>
           <div className="contenedor_central">
            <Boton name="Nueva cuenta de usuario" onClick={() =>registroUsuario()}></Boton>
            <Boton name="Nueva cuenta de servicio" onClick={() =>registroUsuario()}></Boton> 
          </div>
          <RegistroNuevaCuenta></RegistroNuevaCuenta>
      </IonContent>
    </IonPage>
  );
};

const Boton = (props: { name: React.ReactNode, onClick: () => void}) => 
   (<div className="center-div">
     <IonButton shape="round" onClick={props.onClick}> 
      {props.name}
    </IonButton>
 </div>);
 
function registroUsuario(){

}


const RegistroNuevaCuenta: React.FC = () => {
  const [text, setText] = useState<string>();
  const [number, setNumber] = useState<number>();
  
  return (
    <div className="contenedor_central">
      <strong>Completá tus datos</strong>
      
      <IonItem>
        <IonLabel position="floating">Nombre</IonLabel>
        <IonInput value={text}></IonInput>
      </IonItem>
      <IonItem>
        <IonLabel position="floating">Apellido</IonLabel>
        <IonInput value={text}></IonInput>
      </IonItem>
      <IonItem>
        <IonLabel position="floating">E-mail</IonLabel>
        <IonInput value={text}></IonInput>
      </IonItem>
      <IonItem>
        <IonLabel position="floating">Clave</IonLabel>
        <IonInput value={text}></IonInput>
      </IonItem>


      <p>Start with Ionic <a target="_blank" rel="noopener noreferrer" href="https://ionicframework.com/docs/components">UI Components</a></p>
    </div>
  );
};

1 post - 1 participant

Read full topic


Download mp3 file and store in Ios

$
0
0

Hi Hope you all are doing well. I am new here in ionic and getting problem while storing and downloading file. I want to download a mp3 file and store in IOS but not able to download. My code is below
` downloding(file, name) {
if (this.platform.is(“cordova”)) {

  this.file
    .checkDir(this.file.externalRootDirectory, "Downloads")
    .then(
      // Directory exists, check for file with the same name
      (_) =>
        this.file
          .checkFile(
            this.file.externalRootDirectory,
            "Downloads/" + name + ".mp3"
          )
          .then((_) => {
            alert("A file with the same name already exists!");
          })
          // File does not exist yet, we can save normally
          .catch((err) =>
            this.fileTransfer
              .download(
                file,
                this.file.externalRootDirectory +
                  "/Downloads/" +
                  name +
                  ".mp3"
              )
              .then((entry) => {
                alert("File saved in:  " + entry.nativeURL);
              })
              .catch((err) => {
                alert("Error saving file: " + err.message);
              })
          )
    )
    .catch(
      // Directory does not exists, create a new one
      (err) =>
        this.file
          .createDir(this.file.externalRootDirectory, "Downloads", false)
          .then((response) => {
            alert("New folder created:  " + response.fullPath);
            this.fileTransfer
              .download(
                file,
                this.file.externalRootDirectory +
                  "/Downloads/" +
                  name +
                  ".mp3"
              )
              .then((entry) => {
                alert("File saved in : " + entry.nativeURL);
              })
              .catch((err) => {
                alert("Error saving file:  " + JSON.stringify(err.message));
              });
          })
          .catch((err) => {
            console.log(">>>>>>>>>>>>>>>>>>>>>>>>>", JSON.stringify(err));
            alert(
              'It was not possible to create the dir "downloads". Err: ' +
                JSON.stringify(err.message)
            );
          })
    );
} else {
  // If downloaded by Web Browser
  let link = document.createElement("a");
  link.download = name + ".mp3";
  link.href = file;
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
  link = null;
}

}`

I tried multiple solution from google but all in vain.My error is

Error Link is here https://prnt.sc/uoo4bx

I am to much depressed. Please help me. i would be really thankful to you for such favour.

2 posts - 1 participant

Read full topic

Local-notifications based on calling a function once a day

$
0
0

Hello everyone,

I am working on an app which can store different items (every item contains a title as well as an expiration date) and store these via local-storage on the device. My goal is to calling a function once a day (e.g. 6 am.) that will check if there are items with an expiration date less than five or exactly zero days and if so, the app should fire a notification with these items.

I already implemented the local-storage and am able to get the number of days left to the expiration date (when the app is running). I like to use the Capacitor local-notifications for this task and was looking for some background operation because the notifications need to be fired even if the app is closed.

I was trying to solve this just with the local-notifications but there will be some days without firing a notification so that I am not able to just implement a daily notification. I also read something about the Ionic-Background-Mode but wasn´t able to find a way for calling a function once a day at a specific time.

Has anyone of you some advice or any ideas for solving my problem?

Thanks in advance.

1 post - 1 participant

Read full topic

Ion-fab-list can't exceed parent div(td)

Can't find a solution to display a screen after local notification is received (Alarm App)

$
0
0

I used the cordova-plugin-local-notifications and everything worked fine to receive the notification but I want to show a screen of the alarm! I tried to show an alert when the notification is triggered but it’s opened only inside the app :

this.localNotif.on('trigger').subscribe(res => {
  let msg = res.data ? res.data.mydata : '';
  this.showAlert(res.title, res.text, msg);
});

Can anyone help me to display the alarm interface over any app running?

2 posts - 2 participants

Read full topic

Print IONIC 5 Modal Page

$
0
0

I am trying to print from my IONIC PWA from a Modal Page it ONLY SHOWS 1 page to print and ignores the rest i have tried using @media print still no luck. Can anyone help me on what to do I need to print from a Modal page and i need all its content to print.

1 post - 1 participant

Read full topic

Cannot set background-image in IonCard with inline styles

$
0
0

I am not able to set background image in my ioncard component . Here is my code

    <IonRow>
                  {allCategories.categories.map((item, index) => {
                    return (
                      <IonCol size="6" size-md="4" size-lg="3" key={index}>
                        <IonCard
                          onClick={() => getProducts(item)}
                          style={{
                            backgroundImage: `${item.image}`,
                            backgroundColor: "yellow",
                          }}
                        >
                          {/* <IonImg src={item.image} className="catImage" /> */}.  //this works fine but i want the image to be in background
                          <IonItem>
                            <IonLabel>{item.title}</IonLabel>
                          </IonItem>
                        </IonCard>
                      </IonCol>
                    );
                  })}
                </IonRow>

backgroundColor:“yellow”

seems to work fine as this was just for checking, but i do not see anywhere the background image. “IonImage” tag also works fine but i want the image to be in background…

1 post - 1 participant

Read full topic

Ion header showing whitespace pre-collapse

$
0
0

Hi! I may be misunderstanding Ion headers and collapsing but my assumption was:

  • Ion header pre-collapse is larger
  • Ion header post-collapse is thinner and more manageable

I’m having an issue where my post collapse header is appearing as whitespace in the DOM. I can’t figure out how to hide it until the collapse happens. Am I totally misunderstanding how this works?

This is pre-collapse - whitespace is visible at the top

1

This is post collapse – looks correct

2

Code I’m using

    <IonPage>
      <IonHeader color="primary" translucent="true">
        <IonToolbar color="primary">
          <IonTitle size="medium">Settings</IonTitle>
          <HeaderBar name="Scores page" />
        </IonToolbar>
      </IonHeader>

      <IonContent fullscreen="true">
        
        <IonHeader collapse="condense">
          <IonToolbar color="primary">
            <IonTitle size="large">Settings</IonTitle>
            <HeaderBar name="Scores page" />
          </IonToolbar>
        </IonHeader>

        <TeamMenu name="Team" />
        <TeamMenu name="Team" />
        <TeamMenu name="Team" />
        <TeamMenu name="Team" />
      </IonContent>
    </IonPage>

Any help is appreciated! I’ve tried quite a few things but I’m new to Ionic.

1 post - 1 participant

Read full topic


Ionic-native/sqlite plugin not working in real device

$
0
0

Hi all,

Recently I’m working in a hybrid mobile App based on Ionic and cordova.

The versions installed in my project are as follows:

ionic = 3.9.2
node = v8.9.4
npm = 5.6.0

Angular CLI: 1.6.7
Node: 8.9.4
OS: win32 x64
Angular: 5.2.11
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 7.3.10
@angular-devkit/schematics: 7.3.10
@schematics/angular: 8.3.29
typescript: 2.6.2
webpack: 3.8.1

My aim of work is to save user data for offline use. To solve this purpose I installed the following plugins:

npm i --save @ionic-native/sqlite@4
npm i --save cordova-sqlite-storage@4

As my volume of offline data will be a big one I decided to go with SQLite database.
As a first attempt I tried ionic storage with a combination of localstorage option but that did not work, as after sync half of data it is showing “Quota exceeded” error. The reason I found is local storage having a storage capacity of 5MB max.

Currently when I implemented the SQLite database approach what I experienced is in nested call back the execution get lost and there is no response comes after that even no error in console log too. This issue I’m facing only when running the App from the real android device (A Tablet (android version installed
Lollipop 5.1.1 API level 22). While running from the emulator there is no such issues and all works fine.

Let me explain my code execution

  1. I placed a API call to get some data from server the API call reside under a Service (for Example Service1.ts)

  2. Once I received data from API call I call a function to save the data in offline database. This function body again reside under another Service (for Example Service2.ts)

  3. In my case Service1.ts ----> call API —> get response —> call Service2.ts (specific function to save offline data)

The function I’m using for saving offline data is as follows:

databaseObj.open().then(function() {
debugger;
databaseObj.executeSql(this.queryToDelete, [Field_1_value]).then(function(deleteresponse){
console.log(deleteresponse);
this.queryToDelete = ‘’;
databaseObj.executeSql(this.singleDBQuery, [Field_1_value]).then(function(insertresponse){
console.log(‘Data saved’);
this.singleDBQuery = ‘’;
console.log(insertresponse);
}.bind(this)).catch((inserterror) => {
console.log('Data save error: ’ + inserterror.message);
})
}.bind(this)).catch((deleteerror) => {
console.log('Data deletion error: ’ + deleteerror.message);
});
}.bind(this))

The reason I used bind because while debugging the code attached with real device I found in this function scope after calling the databaseObj.open() I lost the reference of this keyword. Then it only points to windows.
Using bind solved my purpose of retain ‘this’ value but databaseObj.executeSql not giving any response as well as error.

Any suggestion from anyone of the team is really appreciated. As I’m in some strict release plan for this work and this thing is not working at all.

If coding approach wise I’m doing any wrong approach please correct that area also.

Regards,
Sounak

1 post - 1 participant

Read full topic

Read and write files to a network

$
0
0

Hi everybody,
i have to read and write XML files to a shared folder in a company network.
Is this possible?
My Ionic-Android App will run on an Android Tablet.
Any advice appreciated.
Thanks in advance and
kind regards

2 posts - 2 participants

Read full topic

Get Items from a QR-Code

$
0
0

Hello everybody,i have a problem with the transfer of data. So I have a QR scanner that is supposed to scan business cards (which it does). Then when the business cards are scanned, it should output them to me as a kind of item (see picture 1). The QR code for the business cards are output as JSON (see picture 2). Somehow I can’t get him to output them to me as an item, I’ve tried everything possible, but somehow I don’t get it.

Picture 1:
pic1

Picture 2:
pic2

how i tried to get what i want (it looks a bit stupid, but if you don’t have any ideas after a while, you test everything :D. In the beginning I knew what I was doing, but after a while I somehow tried, delete and reassemble all kinds of things.):

 saveQR() {
      this.visitenkarteService.addQR(this.scanResult).then(qrcode => {
      this.qrcode = this.scanResult;
      console.log('saveQR ' + this.qrcode.toString);
      this.qrcodeTitel = this.scanResult.toString.title;
      console.log('qrcodeTOstring ' + this.qrcode.toString);
      console.log('qrcodeTOstringTITLE ' + this.qrcodeTitel);
     // console.log('StrinGtest: ' + JSON.stringify(this.scanResult));
     // this.qrcodeName = this.scanResult.name;
     // this.qrcodeTelefon = this.scanResult.telefon;
     // this.showToast('QR-Code Hinzugefügt!');
    //  this.timecreate = Date.now();
      this.loadQR();
      console.log(this.timecreate);
//      const dateFormat = Date.now()[0];
//      console.log(dateFormat);
  }); }

here i tried to show me with a button:

  loadQR() {
  this.visitenkarteService.getQR().then(qrcode => {
    this.qrcode = this.scanResult;
    let result: any;
    result = {
      title: qrcode.title,
      name: qrcode.name,
      telefon: qrcode.telefon
      };
//    this.qrcode = JSON.stringify(result);
    console.log('biggi' + JSON.stringify(result));
//    this.qrcodeTitel = JSON.stringify(this.scanResult.title);
//    console.log('HIER IST der titel: ' + JSON.stringify(this.scanResult.title));
 //   console.log('HIER IST TITEL222: ' + this.qrcodeTitel);
  //  this.qrcodeTelefon = JSON.stringify(this.scanResult.telefon);
  }); }

my html:

  <ion-list >
  <ion-button expand="full" (click)="loadQR()" color="primary">
      <ion-icon slot="start" name="easel-outline"></ion-icon>
      Update contactlist    
    </ion-button>
    <ion-list-header>
      <ion-label>My Contact</ion-label>
    </ion-list-header>

<!--    <ion-item-sliding *ngFor="let item of items"> -->
      <ion-item *ngFor="let item of qrcode" color="light">
        <ion-label text-wrap>
          <h3>Titel: {{ item.title }}</h3>
          <p>Name:  {{ item.name }}</p>
          <ion-text color="secondary">
          <p>Telefon: {{ item.telfon }}</p>
          </ion-text>
        </ion-label>
      </ion-item>

<!--      <ion-item-options side="end">
        <ion-item-option color="danger" (click)="deleteItem(item)">Delete</ion-item-option>
      </ion-item-options> -->
  </ion-list>

I would be happy about any hints, tips or whatever. Thanks for your effort, even if you only had a look :slight_smile:

1 post - 1 participant

Read full topic

Ionic apk, video memory leak

$
0
0

Hi, i’ve made an apk that plays some video but after a while the app is open the RAM fills up and it closes.
I’ve made some analysis with Android Studio and the volume of data in the ram grows slowly.
From logs i can see that the system kill the app but there’s no errors.
Doing some tests i noticed that the problem is about the video.
The objects I used are emptied and they should free up memory, but it doesn’t.
I’ve tried a reboot but the memory occupy is still the same.
Has anyone had the same problem? Or does you know how to fix it?

This is the link: https://stackblitz.com/edit/ionic-uxx8bp
Thank you

1 post - 1 participant

Read full topic

I'm getting design and ripple effect issues in Android 6 and 7 device. Please help me

$
0
0

Hi,
i’m getting design and ripple effect issues in Android 6 and 7 device.

i have checked on Android 10 that is looking good but the lower versions of android, i’m getting these type of issues.

Please help me on these.

-> The below screens are my output in chrome:

-> In real device alignment is missing and plus icon is missing. please find the image attached below.
( Android 6 )

1 post - 1 participant

Read full topic

Angular App import to the ionic

React direct link with params

$
0
0

Hi,
I am trying to create url with params
<Route path="/updatecard/:uniqueKey" component={UpdateCard} />
it works if I do history.push("/updatecard/one")
but if i try to access url direcly using localhsot:4002/updatecard/one i am getting error and blank screen.
what am I missing ?
with react router is works fine but for some reason its not working with ionic.

1 post - 1 participant

Read full topic


React Router broken on Safari 14

$
0
0

I just upgraded to OS X Catalina 10.15.7 which installs a new version of Safari v14.0. After the upgrade my React apps were broken in Safari, but fine in Chrome. When clicking on a menu item I get the message “This webpage was reloaded because a problem occured”, so I am unable to navigate in the app at all. I get the same behaviour with a clean sidemenu starter app, and I’m using Ionic 6.11.9.

Regards,
.cg.

1 post - 1 participant

Read full topic

Ionic App and OS smartphones

$
0
0

Hi. I am new with Ionic. I wonder, does ionic app work in every ios and android smartphones? which are its limitations?

1 post - 1 participant

Read full topic

Native advanced admob (ionic)

Bug: Need Help on it

Recommendations for/against reusable components as a way to avoid code duplication

$
0
0

Hi,
Is there literature on best practices/cautions for creating reusable components? I’ve seen and heard references to this not being a recommended way of working with Ionic framework, at the same time, I’ve read a lot of feedback on having to duplicate html across pages otherwise. Just picking the community’s thoughts on this?

I use Ionic v4 and am interesting in avoiding copying/pasting headers and footers.

Example:

As opposed to:

...

1 post - 1 participant

Read full topic

Viewing all 49253 articles
Browse latest View live


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