Comments (32)
@k-srikanth You need to listen to the 'deviceready' event before calling cordova, because it is not available before that.
document.addEventListener('deviceready', () => {
const permissions = cordova.plugins.permissions;
// Your code here
from cordova-plugin-android-permissions.
please give me the exactly answer :(
from cordova-plugin-android-permissions.
Can you give me some log or more information?
from cordova-plugin-android-permissions.
hi @k-srikanth solved problem? close the ticket)
from cordova-plugin-android-permissions.
Dear NeoLSN,
Issue is resolved, i forgot to include cordova file.
Thanks for your kind support.
On Fri, Nov 18, 2016 at 11:29 AM, ninxxxxx [email protected] wrote:
please give me the exactly answer :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#13 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGPWyC-jHIoN-0dArB9q9XPzC86EyiOtks5q_T6kgaJpZM4J6R8u
.
from cordova-plugin-android-permissions.
@WuglyakBolgoink as you answer "forget to include file" means..in which file and what you add or import ??
from cordova-plugin-android-permissions.
@amolumesh12 do u mean me or @k-srikanth ?
from cordova-plugin-android-permissions.
sorry .. i want to ask to @k-srikanth actually...but if you know what is solution then please tell me
from cordova-plugin-android-permissions.
@amolumesh12 do u have problem with this?
from cordova-plugin-android-permissions.
yes i have same problem..error message showing at "this" keyword..in my code..but as he said solution is "including file " that i didnt getting..where should i add ?
from cordova-plugin-android-permissions.
from cordova-plugin-android-permissions.
from cordova-plugin-android-permissions.
@amolumesh12 can you show your code, if it possible? and which error?
from cordova-plugin-android-permissions.
Cannot read property 'Permissions' of undefined" this error as mentioned in above title ??
from cordova-plugin-android-permissions.
my code : canvas-draw .ts file code..and error occur is "Cannot read property 'Permissions' of undefined"
please check below code and correct me
import { Component, ViewChild, Renderer } from '@angular/core';
import { Platform } from 'ionic-angular';
import { Camera, CameraOptions } from '@ionic-native/camera';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AlertController} from 'ionic-angular';
import { FilePath } from '@ionic-native/file-path';
import { IonicImageViewerModule } from 'ionic-img-viewer';
import { AndroidPermissions } from '@ionic-native/android-permissions';
//import { SignaturePad } from 'angular2-signaturepad/signature-pad';
// import { CanvasDraw } from './canvas-draw/canvas-draw';
@component({
selector: 'canvas-draw',
templateUrl: 'canvas-draw.html'
})
export class CanvasDraw {
touchstartListener = (ev) => this.handleStart((ev));
touchmoveListener = (ev) => this.handleMove((ev));
@ViewChild('myCanvas') canvas: any ;
androidPermissions;
//PERMISSION;
//destinationType': this.camera.DestinationType.DATA_URL,
CANVAS_width= 500;
CANVAS_height= 700;
canvasElement: any;
lastX: number;
lastY: number;
public photos : any;
base64Image:any;
// public image:string;
lastImage;
selectedImagePath;
currentColour: string = '#1abc9c';
availableColours: any;
brushSize: number = 10;
// public signaturePadOptions : Object = {
// 'minWidth': 2,
// 'canvasWidth': 340,
// 'canvasHeight': 200
// };
constructor(public platform: Platform, public renderer: Renderer,public camera : Camera,public navCtrl: NavController, public navParams: NavParams,public alertCtrl: AlertController,public filePath: FilePath, androidPermissions: AndroidPermissions)
{
console.log('Hello CanvasDraw Component');
platform.ready().then(() => {
androidPermissions.requestPermissions(
[
androidPermissions.PERMISSION.CAMERA,
// androidPermissions.PERMISSION.CALL_PHONE,
androidPermissions.PERMISSION.GET_ACCOUNTS,
androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE,
androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE
]
);
})
this.availableColours = [
'#1abc9c',
'#3498db',
'#9b59b6',
'#e67e22',
'#e74c3c'
];
}
ngAfterViewInit(){
this.canvasElement = this.canvas.nativeElement;
this.renderer.setElementAttribute(this.canvasElement, 'width', this.platform.width() + '');
this.renderer.setElementAttribute(this.canvasElement, 'height', this.platform.height() + '');
}
ngOnInit() {
this.photos = [];
}
changeColour(colour){
this.currentColour = colour;
}
changeSize(size){
this.brushSize = size;
}
handleStart(ev){
this.lastX = ev.touches[0].pageX;
this.lastY = ev.touches[0].pageY;
}
handleMove(ev){
let ctx = this.canvasElement.getContext('2d');
let currentX = ev.touches[0].pageX;
let currentY = ev.touches[0].pageY;
//this.image = this.canvas.toDataURL();
ctx.beginPath();
ctx.lineJoin = "round";
ctx.moveTo(this.lastX, this.lastY);
ctx.lineTo(currentX, currentY);
ctx.closePath();
ctx.strokeStyle = this.currentColour;
ctx.lineWidth = this.brushSize;
ctx.stroke();
this.lastX = currentX;
this.lastY = currentY;
}
clearCanvas(){
let ctx = this.canvasElement.getContext('2d');
ctx.clearRect(0, 0, this.canvasElement.width, this.canvasElement.height);
//this.canvasElement.addEventListener('touchstart', ev => this.handleStart(ev));
//this.canvasElement.addEventListener('touchmove', ev => this.handleMove(ev));
}
takePhoto() {
var image = new Image();
let ctx = this.canvasElement.getContext('2d');
const options : CameraOptions = {
quality: 100, // picture quality
targetWidth:300,
targetHeight:300,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation:true,
allowEdit:true,
}
this.camera.getPicture(options) .then((imageData) => {
this.base64Image = "data:image/jpeg;base64," + imageData;
image.src=this.base64Image;
ctx.drawImage(image, 0, 0, image.width,image.height, // source rectangle
0, 0, this.CANVAS_width, this.CANVAS_height);
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.CAMERA).then(
result => console.log('Has permission?',result.hasPermission),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.CAMERA)
);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
this.canvasElement.addEventListener('touchstart', ev => this.handleStart(ev));
this.canvasElement.addEventListener('touchmove', ev => this.handleMove(ev));
}, (err) => {
console.log(err);
});
}
}
from cordova-plugin-android-permissions.
@amolumesh12
import { AndroidPermissions } from '';
why this is empty?
from cordova-plugin-android-permissions.
no that is not empty..i already put it as import { AndroidPermissions } from '@ionic-native/android-permissions';
from cordova-plugin-android-permissions.
@ionic-native/android-permissions...from filed is not empty....problem during copy paste here
from cordova-plugin-android-permissions.
i wrote it as ionicnative/android permisssion .
from cordova-plugin-android-permissions.
plus @ symbol at start
from cordova-plugin-android-permissions.
type script error ..i am not able to understand
from cordova-plugin-android-permissions.
@amolumesh12 wait a bit, and try to write 1 comment and not 100 with 1 word 😉
did you do this: https://ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module?
from cordova-plugin-android-permissions.
from cordova-plugin-android-permissions.
@amolumesh12
so... what I did:
- install plugins
ionic cordova plugin add cordova-plugin-android-permissions --save
npm install --save @ionic-native/android-permissions
- add in
src/app/app.module.ts
import { AndroidPermissions } from '@ionic-native/android-permissions';
@NgModule({
...,
providers: [
...,
AndroidPermissions
]
})
in any component:
import { AndroidPermissions } from '@ionic-native/android-permissions';
constructor(private androidPermissions: AndroidPermissions) {
console.log('Hello PermisComponent Component');
this.text = 'AndroidPermissions: ';
this.androidPermissions
.checkPermission(this.androidPermissions.PERMISSION.CAMERA)
.then(
(result) => {
console.log('result:' + JSON.stringify(result));
console.log('Has permission? ' + result.hasPermission);
this.text += JSON.stringify(result.hasPermission);
if (!result.hasPermission) {
this.androidPermissions
.requestPermission(this.androidPermissions.PERMISSION.CAMERA)
.then((status) => {
console.log('status:' + JSON.stringify(status));
},
(error) => {
console.warn('Camera permission is not turned on');
console.log(error);
});
}
},
(error) => {
console.log(error);
}
);
}
and all work perfect. Try my steps and find your error. Maybe you missed something.
from cordova-plugin-android-permissions.
where should i add this your below code...in my code ..in takephoto() function or where ??
import { AndroidPermissions } from '@ionic-native/android-permissions';
constructor(private androidPermissions: AndroidPermissions) {
console.log('Hello PermisComponent Component');
this.text = 'AndroidPermissions: ';
this.androidPermissions
.checkPermission(this.androidPermissions.PERMISSION.CAMERA)
.then(
(result) => {
console.log('result:' + JSON.stringify(result));
console.log('Has permission? ' + result.hasPermission);
this.text += JSON.stringify(result.hasPermission);
if (!result.hasPermission) {
this.androidPermissions
.requestPermission(this.androidPermissions.PERMISSION.CAMERA)
.then((status) => {
console.log('status:' + JSON.stringify(status));
},
(error) => {
console.warn('Camera permission is not turned on');
console.log(error);
});
}
},
(error) => {
console.log(error);
}
);
}
from cordova-plugin-android-permissions.
@amolumesh12
first - replace this
platform.ready().then(() => {
androidPermissions.requestPermissions(
with this and compile
platform.ready().then(() => {
this.androidPermissions.requestPermissions(
second -> fix import
before
import { AndroidPermissions } from '';
after
import { AndroidPermissions } from '@ionic-native/android-permissions';
PS: I don't know, if you need check
platform.ready()
, because your component started later asplatform.ready()
...
memo:
you can write your source code in comments with code-higlight. In this case write 3x times "" before code and 3x times "
" after your code!
For example:
> ```ts
> <my code>
> ```
from cordova-plugin-android-permissions.
from cordova-plugin-android-permissions.
can you give me your e-mail id please i will send my code .ts file
from cordova-plugin-android-permissions.
i send the my code typescript file check it
from cordova-plugin-android-permissions.
@WuglyakBolgoink -can you pls help me. I am trying to provide camera permissions to my android mobile app. I tried your code, but it never gets to permissions code. i don;t see any popup coming to ask permission. I am using some other camera module not ionic , does that matter? How I can provide run time camera permissions to my angular mobile app, pls provide your inputs.
from cordova-plugin-android-permissions.
Have you add any permission declarations on config.xml
file?
Like this way - Camera Plugin
If you didn't do this, even you call the API, there won't be any popups showing.
from cordova-plugin-android-permissions.
Yes, i had missed that. no where it was mentioned. I got it working now. Thanks for your code.
from cordova-plugin-android-permissions.
Related Issues (20)
- NFC permissions Not Working HOT 1
- Cordova Permissions not working Quasar HOT 1
- Any way to "Predict" if User will be prompted for Permission? HOT 3
- How can i check `MANAGE_EXTERNAL_STORAGE`(all file access) in android? HOT 7
- BLUETOOTH_CONNECT permission missing in permissions.js HOT 2
- Background Location permission issue HOT 5
- BLUETOOTH_CONNECT + BLUETOOTH_SCAN missing for Android +10 HOT 4
- plugins/cordova-plug…w/permissions.js:38 Uncaught SyntaxError: Unexpected token ':' HOT 1
- Support Android 13 (API 33) HOT 5
- BLUETOOTH_SCAN doesn't show confirm dialog to the user HOT 4
- Android 13 SDK 33 - no dialog HOT 5
- uses-feature and camera request in Ionic 6 HOT 3
- POST_NOTIFICATION not working HOT 15
- Camera permission is not turned on?? HOT 1
- android build faild HOT 1
- Permissions not popping up HOT 10
- Storage permission not showing up HOT 2
- BSF Cordova Ecosystem Crowdfunding Plan HOT 2
- POST_NOTIFICATIONS don't work for Android 10 HOT 1
- Trouble with requesting SCHEDULE_EXACT_ALARM permission for Android 14 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-android-permissions.