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

How to implement a QR Scanner in Ionic 4? Camera not showing

$
0
0

@feliperiverot wrote:

I am working with ionic 4 developing and app. I installed the cordova QR Scanner plugin, because I need the QR functionality

I followed the tutorial, but the camera is not showing. here is the ts script:

import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner/ngx';

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

  constructor(public modalController: ModalController,private qrScanner: QRScanner) { }

  ngOnInit() {
  }

    dismiss() {
    // using the injected ModalController this page
    // can "dismiss" itself and optionally pass back data

    this.modalController.dismiss();
  }

  scandata(){


      this.qrScanner.prepare()
  .then((status: QRScannerStatus) => {



     if (status.authorized) {
       // camera permission was granted

        this.qrScanner.show();
       // start scanning
       let scanSub = this.qrScanner.scan().subscribe((text: string) => {
         console.log('Scanned something', text);

         this.qrScanner.hide(); // hide camera preview
         scanSub.unsubscribe(); // stop scanning
       });

     } else if (status.denied) {

       // camera permission was permanently denied
       // you must use QRScanner.openSettings() method to guide the user to the settings page
       // then they can grant the permission from there
     } else {
       // permission was denied, but not permanently. You can ask for permission again at a later time.
     }
  })
  .catch((e: any) => console.log('Error is', e));



  }//

}

After some tested I didn’t found any error. After some researched I got this, the camera is working but under app. The layers and html tags are above the camera. Then I follow this tutorial, and the camera still is not showing.

The fix according to the tutorial and others forum is to add a css class to ion-app tag, like this:

CCS

ion-app.cameraView, ion-app.cameraView ion-content, ion-app.cameraView .nav-decor {
  background: transparent none !important; 
}

This css code, I added to global.scss and app.component.scss files.

And then is the updated function:

 scandata(){

        (window.document.querySelector('ion-app') as HTMLElement).classList.add('cameraView');
         (window.document.querySelector('body') as HTMLElement).classList.add('cameraView');
          (window.document.querySelector('ion-router-outlet') as HTMLElement).classList.add('cameraView');



      this.qrScanner.prepare()
  .then((status: QRScannerStatus) => {



     if (status.authorized) {
       // camera permission was granted

        this.qrScanner.show();
       // start scanning
       let scanSub = this.qrScanner.scan().subscribe((text: string) => {
         alert('Scanned something');

         this.qrScanner.hide(); // hide camera preview
         scanSub.unsubscribe(); // stop scanning
       });

     } else if (status.denied) {

       // camera permission was permanently denied
       // you must use QRScanner.openSettings() method to guide the user to the settings page
       // then they can grant the permission from there
     } else {
       // permission was denied, but not permanently. You can ask for permission again at a later time.
     }
  })
  .catch((e: any) => console.log('Error is', e));



  }//

But the camera still not showing here are some screenschots.

The page, is completely blank with only a button with the click function that calls the scandata() method enter image description here

When I clicked the “default” button A dialog box appears asking for permission to use the camera:

enter image description here

I click on the “allow” button, but still the camera, is not working.

enter image description here

I dont know what else I can do.

Posts: 1

Participants: 1

Read full topic


Why npm install doesnt install angular/dev-kit

$
0
0

@itosoft wrote:

hi while i am using npm to install dependencies at the end i got this error:

and also i can not serve ionic because of a despondency [![enter image description here]

here is the part of log

17252 verbose optional SKIPPING OPTIONAL DEPENDENCY:
17252 verbose optional The operation was rejected by your operating system.
17252 verbose optional SKIPPING OPTIONAL DEPENDENCY: It's possible that the file was already in use (by a text editor or antivirus),
17252 verbose optional SKIPPING OPTIONAL DEPENDENCY: or that you lack permissions to access it.
17252 verbose optional SKIPPING OPTIONAL DEPENDENCY:
17252 verbose optional SKIPPING OPTIONAL DEPENDENCY: If you believe this might be a permissions issue, please double-check the
17252 verbose optional SKIPPING OPTIONAL DEPENDENCY: permissions of the file and its containing directories, or try running
17252 verbose optional SKIPPING OPTIONAL DEPENDENCY: the command again as root/Administrator.
17253 verbose stack Error: ENOENT: no such file or directory, rename 'F:\ionic\itosoft\amnasnad-lts\node_modules\@angular-devkit\build-angular\node_modules\parse5' -> 'F:\ionic\itosoft\amnasnad-lts\node_modules\@angular-devkit\build-angular\node_modules\.parse5.DELETE'
17254 verbose cwd F:\ionic\itosoft\amnasnad-lts
17255 verbose Windows_NT 10.0.18362
17256 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
17257 verbose node v12.16.1
17258 verbose npm  v6.13.4
17259 error code ENOENT
17260 error syscall rename
17261 error path F:\ionic\itosoft\amnasnad-lts\node_modules\@angular-devkit\build-angular\node_modules\parse5
17262 error dest F:\ionic\itosoft\amnasnad-lts\node_modules\@angular-devkit\build-angular\node_modules\.parse5.DELETE
17263 error errno -4058
17264 error enoent ENOENT: no such file or directory, rename 'F:\ionic\itosoft\amnasnad-lts\node_modules\@angular-devkit\build-angular\node_modules\parse5' -> 'F:\ionic\itosoft\amnasnad-lts\node_modules\@angular-devkit\build-angular\node_modules\.parse5.DELETE'
17265 error enoent This is related to npm not being able to find a file.
17266 verbose exit [ -4058, true ]

full log at https://gofile.io/?c=dKTtf3

Posts: 2

Participants: 2

Read full topic

How to set value dynamically default value in ion-select-option

$
0
0

@UnnatiPatadia wrote:

I’m using Ionic 4.
I want to show a default value in ion-select-option.
Option’s values come from the server.
API works all values show but on click of ion-select.
But I want to show the default value.

Response

{"success":1,"service_details":[{"id":"1","name":"Job\/Service","status":"1"},{"id":"2","name":"Student","status":"1"},{"id":"3","name":"House Wife","status":"1"},{"id":"4","name":"Business","status":"1"}]}

register.ts

 userData = { "fname": "", "lname": "", "contact_no": "", "email_id": "", "password": "", 
 "business_type": "", "organization_name": "", "designation": "", };

constructor () { 
    this.userData.business_type = "1";
}

getAllService(){
    let loading = this.loadingCtrl.create({
      spinner: 'circles',
      message: 'Please wait...'
    }).then(loading => loading.present());

    this.authService.getData("get_all_service_type.php").then((result) => {
      this.items = result;
        this.success = this.items.success;
        console.log(this.success);

        if (this.success == 1) {
          this.loadingCtrl.dismiss();
          this.serviceData = this.items.service_details;
          console.log(this.serviceData);
        } else {
          this.message = this.items.message;
          this.loadingCtrl.dismiss();
        }

    }, (err) => {
       this.loadingCtrl.dismiss();
      console.log("Error", err);
    });
  } 

register.html

 <ion-item>
     <ion-label>Occupation </ion-label>
     <ion-select value="Job/Service" (ionChange)="optionsFn()" name="business_type" [(ngModel)]="userData.business_type">
         <div *ngFor="let item of serviceData">
             <ion-select-option value="{{item.id}}">{{item.name}}
             </ion-select-option>
         </div>
      </ion-select>
 </ion-item>

OR

<ion-select (ionChange)="optionsFn()" name="business_type" [(ngModel)]="userData.business_type">
  <ion-select-option *ngFor="let item of serviceData" value="{{item.id}}" [selected]="userData.business_type == item.name">{{item.name}}</ion-select-option>
</ion-select>

Posts: 1

Participants: 1

Read full topic

Ionic 4 app run after swipe out/killed

$
0
0

@prabhashi1 wrote:

I need to call a method in every second (my app include a count down) and it’s working when the app in the thread but once I swipe out the app the countdown stops. How can I manage to do this?

Posts: 1

Participants: 1

Read full topic

Amount validation

$
0
0

@mehraj786 wrote:

hi i want to validate amount like this 23.56 in ionic 4 for input type number and i dont want dash(-) symbol to accept this input… please let me know how to achive this from past one month i am having this issue

Posts: 1

Participants: 1

Read full topic

Ionic 3 add accessibility aria-labelledby

$
0
0

@xzetic wrote:

Hi, I’m only new here. I just need some help on my company accessibility requirements.
I’m using ion-spinner component for our loading application. We want to add element such as
role=“img” aria-labelledby=“idloading” to its auto generated SVG.

For example:
svg role=“img” aria-labelledby=“idloading” viewBox=“0 0 64 64” style=“animation-duration: 750ms;”></svg

image

Anyone know how to access the svg to add this elements? Thanks in advance!

Posts: 1

Participants: 1

Read full topic

Ion content

$
0
0

@Mmadzharov wrote:

Hey I have a question is it ok to add elements between the ion-content and ion-footer:
< ion-content >…</ ion-content>
< div>Some static content< /div>
< ion-footer>< /ion-footer>.

Posts: 1

Participants: 1

Read full topic

Where sqlite store database file on Android

$
0
0

@anton_klochko wrote:

Good day! I am use Cordova SQLite Plugin for offline database. it work normally but i have know where the db file is located and share file with other person. Could anyone help please to find it on android devices.

I use…

      const DB_NAME: string = '__ionicstorage';
     const win: any = window;

    this._db = win.sqlitePlugin.openDatabase({
      name: DB_NAME,
      location: 2,
      createFromLocation: 0
    });

Posts: 1

Participants: 1

Read full topic


How can i load media files like instagram and facebook

$
0
0

@VigneshBalakrishnan wrote:

Hi all,
I’m creating a social application where users can upload their images, videos and audio. And i’ll load the media files from s3 through URL. Now i want to make the user experience better so I’m thinking of making it like instagram and facebook. When the media file is big or network is down to show a loader.
Can any one help me, Thanks in advance.

Posts: 1

Participants: 1

Read full topic

Embedding a component on an external web site

$
0
0

@conexcol wrote:

Hi, we have a pwa (ionic4+angular8) and we would like to be able to embed a single component on external sites. The component uses parts of the whole application to produce a card. We would like that card to be shown on any external website and when clicking on it take the user to our app.

What is the best way to embed a component inside an external webpage?

Thanks!

Posts: 1

Participants: 1

Read full topic

Angular Element + cordova

$
0
0

@NurGuz wrote:

Hello guys,

I am testing from an android device.

when I add to my IONIC application a WebComponent generated with Angular Elements and proceed to check if the platform is cordova, it doesn’t work.

This is because if I add a webcomponent it no longer recognizes cordova as a platform. But if I remove the webcomponent, if cordova recognizes me

Posts: 1

Participants: 1

Read full topic

Loading post from Wordpress category (Api Rest V2)

$
0
0

@interartivity wrote:

Hi,

I’m testing Ionic with Wordpress and I’m loading all posts from my web with this service code:

export class WordpressService {
 
  url = `https://mydomain.com/wp-json/wp/v2/`;
  totalPosts = null;
  pages: any;
 
  constructor(private http: HttpClient) { }
 
  getPosts(page = 1): Observable<any[]> {
    let options = {
      observe: "response" as 'body',
      params: {
        per_page: '5',
        page: ''+page
      }
    };
 
    return this.http.get<any[]>(`${this.url}posts?_embed`, options).pipe(
      map(resp => {
        this.pages = resp['headers'].get('x-wp-totalpages');
        this.totalPosts = resp['headers'].get('x-wp-total');
 
        let data = resp['body'];
 
        for (let post of data) {
          post.media_url = post['_embedded']['wp:featuredmedia'][0]['media_details'].sizes['medium'].source_url;
        }
        return data;
      })
    )
  }
 
  getPostContent(id) {
    return this.http.get(`${this.url}posts/${id}?_embed`).pipe(
      map(post => {
        post['media_url'] = post['_embedded']['wp:featuredmedia'][0]['media_details'].sizes['medium'].source_url;
        return post;
      })
    )
  }
}

It’s working fine (load posts, featured images and parse HTML text) but I need to load posts from one category only.

Any ideas?

Thanks in advance :wink:

Posts: 2

Participants: 2

Read full topic

How to get notification in notification bar on device when it receives the notification as foreground

$
0
0

@Zagrev wrote:

I am using the plugin with cordova-plugin-with-dependecy-updated.
But the notification is shown on notification bar when the app is in background or closed.
I wanna to get the notification in regardless the app is in foreground or background

Posts: 1

Participants: 1

Read full topic

Popover width auto

How to pass data from page to modal in ionic 4 app?

$
0
0

@Sweg wrote:

In my ionic app, I am trying to navigate from a page to a modal, & display some data which I passed to the Modal.

Below I am creating an ActionSheet & assigning a button to display the modal:

this.actionSheet.buttons = [
{
          text: 'View all comments',
          handler: () => {          
            this.modalCtrl.create({
              component: CommentsPage,
              componentProps: {
                'post': post
              }
            }
            ).then(modal => {
              this.modal = modal;
              modal.present();
            });
          }
        }
];

The modal successfully appears with blank code like so:

export class CommentsPage implements OnInit {
  post: any = {};
  constructor() { }
  ngOnInit() {
  }
}

But I want to get the post data which I added to the componentProps inside the ModalController.

I tried to retrieve this using ActivatedRoute below, but am getting this error:

Property ‘activatedRoute’ does not exist on type ‘CommentsPage’.ts

export class CommentsPage implements OnInit {
  post: any = {};
  constructor(activatedRoute: ActivatedRoute) { }
  ngOnInit() {
    this.post = this.activatedRoute.snapshot.paramMap.get('myid');
  }
}

Am I passing the post value correctly? If so, how can I use that value inside the modal?

Posts: 4

Participants: 2

Read full topic


Ionic Cordova running on one android device, but not on another

$
0
0

@Sweg wrote:

I am able to run my ionic 4 app on my own device by running ionic cordova run android.

However, I’m now trying to use it on another older android device, so I can do some testing.

When I connect the older device & run the same command above, I’m getting the following logged to the console:

Preparing Firebase on Android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\damie\AppData\Local\Android\sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app

Configure project :app
WARNING: Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: API ‘variant.getAssemble()’ is obsolete and has been replaced with ‘variant.getAssembleProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getAssemble(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API ‘variantOutput.getProcessResources()’ is obsolete and has been replaced with ‘variantOutput.getProcessResourcesProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API ‘variantOutput.getProcessManifest()’ is obsolete and has been replaced with ‘variantOutput.getProcessManifestProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessManifest(), use -Pandroid.debug.obsoleteApi=true on the command line to display a
stack trace.
WARNING: API ‘variant.getMergeResources()’ is obsolete and has been replaced with ‘variant.getMergeResourcesProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API ‘variant.getMergeAssets()’ is obsolete and has been replaced with ‘variant.getMergeAssetsProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API ‘variant.getPackageApplication()’ is obsolete and has been replaced with ‘variant.getPackageApplicationProvider()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getPackageApplication(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API ‘variant.getExternalNativeBuildTasks()’ is obsolete and has been replaced with ‘variant.getExternalNativeBuildProviders()’.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getExternalNativeBuildTasks(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

Task :app:preBuild UP-TO-DATE
Task :CordovaLib:preBuild UP-TO-DATE
Task :CordovaLib:preDebugBuild UP-TO-DATE
Task :CordovaLib:checkDebugManifest UP-TO-DATE
Task :CordovaLib:processDebugManifest UP-TO-DATE
Task :app:preDebugBuild
FAILURE: Build failed with an exception. FAILED

I’m afraid to change some things at the moment, because it works on one device, & I’m worried in case any changes I make break existing functionality.

I can provide whatever code is required to help narrow down the problem also.

Posts: 1

Participants: 1

Read full topic

In Ionic 5, should we still use HammerJS for standard gestures?

$
0
0

@Ryan119 wrote:

I noticed that Ionic5 has included gesture support but it looks like that’s really geared towards custom gestures. Is it still recommended to use HammerJS for standard swipe, press, etc?

Posts: 1

Participants: 1

Read full topic

Ionic 3 app initialization guidelines

$
0
0

@lsantaniello wrote:

Hi all,
I need to initialize my app and when initialization has been completed, open the first page.

During inizialization, I need to read from storage and load data from the server.

In my app, the home page costructor is called before that initialization has been completed.

I’d like to block with classic loading page and after I redirect the user to home page

What is the best solution for this scenario?

My code:

export class MyApp {

  constructor(...) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      
	  //here I read from storage and load data from the server
	  ...
	  
    });
  }
  
  ..
}

Thanks in advance

Posts: 7

Participants: 2

Read full topic

Question about Notification Push

$
0
0

@srterry wrote:

I know this question is not about Ionic but if anyone could help me. I have a REST conected with my app, builded with node.js, express and mongo. To notify and connect my REST with Firebase, I’m using this plugin(https://www.npmjs.com/package/fcm-node). My problem is that to send a notification, the device token must be registered manually.

image

Is there anyway to do it from REST when User logins automaticall? I’m missing something?

Posts: 1

Participants: 1

Read full topic

How to force user to enable permission oontacts, Location and camera on ionic v3

Viewing all 49526 articles
Browse latest View live


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