I have a screenshot problem

Hi there. Im a Ionic 2 developer from Turkey. Nowadays i try to solve that problem. The project i am developping needs to screenshot feature. Ive added necessary plugin and wrote necessary code as telling on ionic native site. But it doesnt work. the error is “cannot read property ‘save’ of undefined” in console. My code is:
this.screenshot.save(‘jpg’, 80, ‘myscreenshot.jpg’).then(success=>{

The error message is clear, the variable this.screenshot is not a valid object.

What plugin are you using?
What exactly did you do to install it?
What version of Ionic (and ecosystem) are you using?

why isnt it valid? whats correct version?

I use same things on this page: https://ionicframework.com/docs/v2/native/screenshot/
so this plugin: https://github.com/gitawego/cordova-screenshot.git
i installed that plugin and then write said importing plugin codes and function in typescript like this ;

import { Screenshot } from ‘@ionic-native/screenshot’;

constructor(private screenshot: Screenshot) { }

My ionic information is:

Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v7.3.0
Xcode version: Not installed

I dont know ecosystem where can i learn it?


  providers: [

i aldreay added this in app.module.ts file. But it still doesnt work

You can find sample project below and in my opinion you are trying on browser, if you try below project on real device you can see the result :slight_smile: :slight_smile:

btw check console to see the results nothing happen on actual screen

1 Like

I am presenting the same difficulty, can you solve it?

Is Screenshot supposed to work correctly in a browser? Or only if you install the app.

All native plugins need to run on a device.

i am running on a device and their is no response there…

In the docs, it doesn’t mention windows as being a supported platform. That might be your problem