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

Ionic html in angular project

$
0
0

@KishanR wrote:

Hi All,
I need to on how to use ionic HTML content into my angular project. I have added the HTML code which I used

<ion-segment [(ngModel)]="galleryType" color="blue">
    <ion-segment-button value="regular">
      Regular
    </ion-segment-button>
    <ion-segment-button value="pinerest" (click)="nativePage()">
      Pinterest
</ion-segment-button>
  </ion-segment>

When I give ng serve to my angular project the above HTML code is not working I am just able to see Regular and Pinterest in a test format. Can some please help me with this.

Thanks
Kishan

Posts: 1

Participants: 1

Read full topic


Youtube Tv

Error while saving image to gallery on ios

$
0
0

@lytion wrote:

Hi,

I have some problems when I want to save an image in the gallery in ios.
I tried differents methods but none works…

In my code the variable base64Data is a string which contain the base64 image (“data:image/png;base64,…”)

I tried with the base64ToGallery plugin:

this.base64ToGallery.base64ToGallery(base64Data, {prefix: 'img_', mediaScanner: false}).then(
			res => this.alertCtrl.create({title: res}).present(),
			err => this.alertCtrl.create({title: err}).present()
		);

But nothing happen with this code. If I set mediaScanner to true the app crash and same thing if I remove the option object (prefix and mediaScanner).

So I tried another solution:

public writeFile(base64Data: any, folderName: string, fileName: any) {
		let contentType = this.getContentType(base64Data);
		let DataBlob = this.base64toBlob(base64Data, contentType);
		// here iam mentioned this line this.file.externalRootDirectory is a native pre-defined file path storage. You can change a file path whatever pre-defined method.
		let filePath = this.file.externalRootDirectory + folderName;
		this.file.writeFile(filePath, fileName, DataBlob, contentType).then((success) => {
			this.alertCtrl.create({title: success}).present();
			console.log("File Writed Successfully", success);
		}).catch((err) => {
			this.alertCtrl.create({title: err.message}).present();
			console.log("Error Occured While Writing File", err);
		})
	}

	//here is the method used to get content type of an bas64 data
	public getContentType(base64Data: any) {
		let block = base64Data.split(";");
		let contentType = block[0].split(":")[1];
		return contentType;
	}

	//here is the method used to convert base64 data to blob data
	public base64toBlob(b64Data, contentType) {
		contentType = contentType || '';
		var sliceSize = 512;
		let byteCharacters = atob(b64Data.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''));
		let byteArrays = [];
		for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
			let slice = byteCharacters.slice(offset, offset + sliceSize);
			let byteNumbers = new Array(slice.length);
			for (let i = 0; i < slice.length; i++) {
				byteNumbers[i] = slice.charCodeAt(i);
			}
			var byteArray = new Uint8Array(byteNumbers);
			byteArrays.push(byteArray);
		}
		let blob = new Blob(byteArrays, {
			type: contentType
		});
		return blob;
	}

Here, this.file.externalRootDirectory is null and I have the error ENCODING_ERR.
So I saw that I can use “file:///” for ios and I got an NOT_FOUND_ERR, I suppose that this is not a good path but I don’t know how to get a good one.

Is there a way to know the good path or a code / plugin to save in the gallery that I didn’t find ?

Thanks for your help.

Posts: 1

Participants: 1

Read full topic

_co.Number is not a function

$
0
0

@rahulsharma991 wrote:

PAGES–Home.ts file

<ion-content padding autohide>
  <ion-fab bottom right #fab>
    <button ion-fab (click)="Number()">
      <ion-icon name="add"></ion-icon>
    </button>
  </ion-fab>

Directive—AutoHide.ts

Number(){
    let add=this.alertcontroller.create({
      title:'Submit Form',
      message:'Enter Number',
      inputs:[{
        type:'number',
        name:'addNumberInput'
      },
        {
          type:'radio',
          label:'Spam',
          value:'Spam'
        },
        {
          type:'radio',
          label:'Not Spam',
          value:'Not Spam'
        },
        {
          type:'textarea',
          name:'Add your Comment',
          placeholder:'Optional'
        }
      ],
      buttons:[{
        text:'Cancel'
      },
        {
          text:'SUBMIT'
        }
      ]
    });
    add.present();
  }

Posts: 1

Participants: 1

Read full topic

Implementing Script in Angular app

$
0
0

@KishanR wrote:

Hi All,
I need to know how to implement the below script in my angular index.html file

<script src='node_modules/@ionic/core/dist/ionic.js'></script>

It is throwing as above URL is not found even though I have installed @ionic/core. Can someone help me with this

Thanks in advance

Kishan

Posts: 1

Participants: 1

Read full topic

IONIC 4 : ion-slide is not catching click after page scroll

$
0
0

@dvtopiya wrote:

I am using ion-slides like below. When I click on ion-slide, it is calling test() method but when I scroll down the page and again tried to click on ion-slide it does not call test() method.
After 30-40 second If I try again it is calling the test() method.

html : 
<ion-slides>
    <ion-slide (click)="test()"> 1 </ion-slide>
    <ion-slide (click)="test()"> 2 </ion-slide>
</ion-slides>

ts:
test()  {
    alert('test');
}

Can anyone please provide any solution on this ?

Posts: 1

Participants: 1

Read full topic

Firebase Cloud Function throwing an error every time (even though it works)

$
0
0

@bmcgowan94 wrote:

Hi, I’ll try and keep this as short as possible.

I’m working on a social app and im currently working on the functionality which allows users to ‘LIke’ or ‘Unlike’ a post.

I’ve implemented this as a cloud function on Firebase, shown here…

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

admin.initializeApp(functions.config().firebase);


/* this cloud function is used to update the likes on a post
- it receives three parameters in the post body 
- and will update those respective fields in the post document (e.g number of likes)
*/

export const updateLikesCount = functions.https.onRequest((request, response) => {

  let body: any;
  if(typeof(request.body) == "string")
  {
    body = JSON.parse(request.body)
  }
  else
  {
    body = request.body;
  }

  console.log(request.body);

  const postId = JSON.parse(request.body).postId;
  const userId = JSON.parse(request.body).userId;
  const action = JSON.parse(request.body).action; // 'like' or 'unlike' 

  // from this data object we can get the value of all the fields in the document
  admin.firestore().collection("posts").doc(postId).get().then((data) => {

    // if likes counts = 0, then assume there are no likes 
    let likesCount = data.data().likesCount || 0;
    // likewise if there are no likes, then assign an empty array
    let likes = data.data().likes || [];

    let updateData = {};

    if(action == "like")
    {
      updateData["likesCount"] = ++likesCount;
      updateData[`likes.${userId}`] = true;
    } 
    else 
    {
      updateData["likesCount"] = --likesCount;
      updateData[`likes.${userId}`] = false;
    }

    admin.firestore().collection("posts").doc(postId).update(updateData).then(() => {
      response.status(200).send("Done")
    }).catch((err) => {
      response.status(err.code).send(err.message);
    })

  }).catch((err) => {
    response.status(err.code).send(err.message);
  })

})

Also, here is the function in my code which calls this function…

 // This function deals with liking or unliking a post
  like(post)
  {
    // Remember, as we are firing a cloud function we need a JSON object to send to it
    // This object creates that JSON object to be sent to the cloud function for evaluation
    let body = 
    {
      postId: post.id, 
      userId: firebase.auth().currentUser.uid, 
      // does the post contain any likes, if so has the current user liked it already, if so then assign to unlike
      action: post.data().likes && post.data().likes[firebase.auth().currentUser.uid] == true ? "unlike" : "like" 
    }

    let toast = this.toastCtrl.create({
      message: "Updating like... please wait"
    });
    
    toast.present();

    // calling our cloud function, and passing in the object of data
    this.http.post("https://us-central1-feedlyapp-4109f.cloudfunctions.net/updateLikesCount", JSON.stringify(body), {
      responseType: "text"
    }).subscribe((data) => {
      console.log(data)

      toast.setMessage("Like updated!");
      
      setTimeout(() => {
        toast.dismiss();
      }, 3000)

    }, (error) => {

      toast.setMessage("An error has occurred. Please try again later.")
      setTimeout(() => {
        toast.dismiss();
      }, 3000)

      console.log(error)
    })

  }

Basically the ‘action’ is sent as a JSON object to the cloud function to be evaluated. If the user has already liked the post, then the action is ‘Unlike’, otherwise it should be ‘Like’.

However, for some reason every time the user clicks on the like button, the toast message saying “An error has occurred. Please try again later” appears… even though the likes/unlikes are updated in my firebase database. I do not understand what is going on, or what the error message means. Please Help! Thanks.

Also, here is the error message… both on the device and in the console.

image

Posts: 1

Participants: 1

Read full topic

I want to use Alert radio button to push a page using the if statement in Ionic 3

$
0
0

@breadedx wrote:

presentPrompt() {
let alert = this.alertCtrl.create({
title: ‘Have units?’,
inputs: [{
type: ‘radio’,
label: ‘Yes’,
value: ‘0’
},
{
type: ‘radio’,
label: ‘No’,
value: ‘1’
}
],
buttons: [{
text: ‘Cancel’,
role: ‘cancel’,
handler: () => {
console.log(‘Cancel clicked’);
}
},
{
text: ‘OK’,
handler: (data: string) => {
console.log(‘OK clicked: Data ->’, JSON.stringify(data));

      if (value == 0) {

        this.navCtrl.push(UnidadePage);

      }
      ifelse(value == 1) {
        this.navCtrl.push(AmbientePage);
      } else {

        console.log("please click one option");

      }
    }
  }
]

});
alert.present();
}

Posts: 1

Participants: 1

Read full topic


Código de barras

$
0
0

@claudecigoularte wrote:

Pessoal. Bom dia. Eu implementei o barcodescanner no meu app, porém, ele fica com uma borda escura, nas laterais. Quero poder colocar a área de leitura, em full. É possível?

Eu sou iniciante. Já encontrei alguns lugares aqui no fórum, que dizem que precisa criar o próprio plugin, mas como não ainda não tenho conhecimento suficiente, espero que possa haver uma alternativa. Outro plugin talvez.

Posts: 1

Participants: 1

Read full topic

Push Notification + Heroku + Postres

Using firebase services without specific plugins

$
0
0

@charlescc wrote:

Hello,

I’m often having problem when working with firebase and different firebase specific plugins, like firebase authentification or firebase messaging (compatibility, performance, …).

It made me wondering, is it possible to use simply firebase plugin in ionic 4, without using those specific plugins, and still use firebase auth and messaging ?

Posts: 1

Participants: 1

Read full topic

Problems getting accounts on device

$
0
0

@estacho999 wrote:

I’m trying to get the accounts registered on the device with the ionic device accounts plugin, however on promise it has not returned anything to me on the console.

My code is:

  testeSemNative() {
    DeviceAccounts.getPlugin().getEmail(
      account => console.log('Account' + account),
      error => console.error(error));

    DeviceAccounts.getPlugin().get(
     accounts => console.dir(accounts),
     error => console.error(error));
  }

  testeComNative() {
    this.deviceAccounts.get()
      .then(accounts => console.log(accounts))
      .catch(error => console.error(error));
  }

I researched in some places, and had a topic suggesting to use another code model, so I tried to perform a test using ionic native, and another test calling the plugin directly, but in both I could not get any results

Posts: 1

Participants: 1

Read full topic

Bluetoothserial not connected

$
0
0

@spigatl wrote:

I try connect with bluetoohserial from mine android phone in my notebook, but not connect. can u help me… this my code. whats wrong i do!?

import { Component } from '@angular/core';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';
import { NavController, LoadingController } from 'ionic-angular';
import { AlertController } from 'ionic-angular';

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'

})
export class HomePage {
    infomation: any = [];
    spiga: any = [];

    constructor(
        public alertCtrl: AlertController,
        public navCtrl: NavController,
        private bluetoothSerial: BluetoothSerial,
        public loadingCtrl: LoadingController) { }

    ionViewDidLoad() {

        this.infomation = { id: "hey it works" };



        this.bluetoothSerial.isEnabled().then(() => {
            console.log("bluetooth is enabled all G");
        }, () => {
            console.log("bluetooth is not enabled trying to enable it");
            this.bluetoothSerial.enable().then(() => {
                console.log("bluetooth got enabled hurray");
            }, () => {
                console.log("user did not enabled");
            })
        });

    }

    connectdevice(devices) {
        this.bluetoothSerial.isEnabled().then((res) => {
            this.bluetoothSerial.list();
            this.bluetoothSerial.connect("00:E1:8C:3F:90:7A");
            this.bluetoothSerial.isConnected().then((res) => {
                console.log("Device connected with successful " + res);
            },
                (error) => {
                    this.showError(error);
                    console.log("could not find unparied devices " + error);
                });

        },
            (error) => {
                this.showError(error);
                console.log("could not find unparied devices " + error);
            });



    }

    discover() {
        let loading = this.loadingCtrl.create({
            spinner: 'bubbles',
            content: `Please wait...`,
            duration: 10000
        });

        loading.present();
        this.bluetoothSerial.discoverUnpaired().then((device) => {
            this.bluetoothSerial.setDeviceDiscoveredListener().subscribe(device => {
                this.spiga = [
                    device
                ];

                console.log(this.spiga);
            });
        },
            (error) => {
                this.showError(error);
                console.log("could not find unparied devices " + error);
            });
    }

    showDevices(title, id, type, address, name) {
        let alert = this.alertCtrl.create({
            title: title,
            message: id + type + address + name,
            buttons: ['OK']
        });
        alert.present();
    }

    showError(info) {
        let alert = this.alertCtrl.create({
            title: "Error",
            message: info,
            buttons: ['OK']
        });
        alert.present();
    }

}

Posts: 1

Participants: 1

Read full topic

LiveReload All The Things not working

$
0
0

@gaiapuffo wrote:

Hi, I work with ionic 4 and I have read this part of ionic article

One of the best features of the CLI is the LiveReload server that gets started when you runionic serve. This allows you to develop your app in the browser and have it update instantly when changes are made to any development files.

But this is not true. I use ionic serve.
After I change some files, 90% of times ionic serve not recompiling nothing and when recompiling I have to wait 20 sec every time!!!

Posts: 1

Participants: 1

Read full topic

Unable to get local issuer certificate

$
0
0

@frankthetiger wrote:

Hi,

I’m a beginner and just installed ionic. I’m getting the “ Unable to get local issuer certificate error ” while issuing the below command,

ionic start helloWorld blank

I have tried executing the below commands, but no luck,

npm config set strict-ssl false
git config http.sslVerify false

and also to set an environment variable NODE_TLS_REJECT_UNAUTHORIZED with value 0.

Does anyone know how to fix this?

image

Posts: 1

Participants: 1

Read full topic


Package conflicts with an existing package

$
0
0

@akiva10b wrote:

I have two version of an app that I want to run on the same phone.
I have changed my config.xml widget id and name, I have change package.json and ionic.config.json and I have changed manifest.json all to have a different name for the app, but still I get this error “Package conflicts with an existing package”

Posts: 1

Participants: 1

Read full topic

Failed Login Session for Twitter Connect Plugin

$
0
0

@setu1421 wrote:

I am trying to use Twitter Connect plugin with firebase for my Ionic 3 application. It was working perfect but now it is throwing Failed Login Session error in the console.

In package.json:

  "dependencies": {
    "@ionic-native/twitter-connect": "^4.19.0",
    "twitter-connect-plugin": "git+https://github.com/chroa/twitter-connect-plugin.git",
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "twitter-connect-plugin": {
        "FABRIC_KEY": "********************",
        "TWITTER_KEY": "****************",
        "TWITTER_SECRET": "******************"
      }
    }
  }

In config.xml:

<plugin name="twitter-connect-plugin" spec="https://github.com/chroa/twitter-connect-plugin">
    <variable name="FABRIC_KEY" value="***********" />
    <variable name="TWITTER_KEY" value="***********" />
    <variable name="TWITTER_SECRET" value="*************" />
</plugin>

I have checked all the keys and they are all correct. Can anyone point me what is the problem here?

Posts: 1

Participants: 1

Read full topic

[ionic4] ion-tab

$
0
0

@idan003 wrote:

Hi Guys,

I have some issue with the ionic tabs RC1,
when i move from page to page with videos its works great, but when i click on back button i still have the audio of the video, in beta 16 is not like that.

there is some solution for that issue?

Ionic:

   ionic (Ionic CLI)             : 4.3.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.0
   @angular-devkit/build-angular : 0.11.4
   @angular-devkit/schematics    : 7.1.4
   @angular/cli                  : 7.1.4
   @ionic/angular-toolkit        : 1.2.2

Tnx

Posts: 1

Participants: 1

Read full topic

HELP my ion-list dont work

$
0
0

@Galvs wrote:

I have a search from my database with json working…
getEvolucoes(){
this.http.get(this.postProv.urlGet()+‘buscaEvolucoesApp.php?ref=’+this.pkidusuario).pipe(map( res => res.json()))
.subscribe(
data => console.log(this.contatos = data),
err => console.log(err)
);
}
But my html dont show de values of fields… Can help me?


<ion-item *ngFor=“let contato of contatos”>

Data:{{ contatos.dataevo }} | Prof: Vanessa Ferreira


{{ contatos.descricaoevo }}




Posts: 1

Participants: 1

Read full topic

Use specific CLI version for project

$
0
0

@shepard wrote:

I have a 3.9.2 angular app that does not build properly with the latest Ionic CLI.
I am installing a local version for the project but need to determine which older CLI would work best.
I have tried CLI 4.0.1 with no luck.
Any suggestions on which CLI version to use?

Posts: 1

Participants: 1

Read full topic

Viewing all 48983 articles
Browse latest View live


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