cordova-plugin-wallpaper icon indicating copy to clipboard operation
cordova-plugin-wallpaper copied to clipboard

Issue while using it in ionic 3

Open yaswanthkata opened this issue 7 years ago • 4 comments

I have tried using this plugin ,but no output.Could you please help me if im dong anything wrong.

window.plugins.wallpaper.setImage(fileEntry.toURL(), function (error) { if (error) { console.error(error); } else { console.log('Success setting wallpaper.'); } });

yaswanthkata avatar Aug 15 '17 09:08 yaswanthkata

Same issue here.I am not getting any output in ionic 3.Anyone help?

cybercodewiz avatar Sep 23 '17 06:09 cybercodewiz

What does file.toUrl() return?

janbaudisch avatar Sep 23 '17 18:09 janbaudisch

Hi, I am building ionic 3 app.Step followed to install cordova-plugin-wallpaper in ionic 3.From app file location in command prompt,i ran "ionic cordova plugin add cordova-plugin-wallpaper" and plugin was installed. Then,in home.ts in home page,i used a function setWall() to use cordova.plugins.wallpaper.setImageHttp(link) to set image from cloud.I used a button in home.html with click to call setWall() in home.ts. Complete code below.

HTML(home.html):

<ion-header>
  <ion-navbar color="dark">
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>appname</ion-title>
  </ion-navbar>
</ion-header>

<ion-content>
                <ion-card>
                    <img src="Cloudinary link"/>
                    <div>wallpaper</div>
                    <button ion-button small (click)="setWall()">
                      <ion-icon name="cloud-download"></ion-icon>
                      <p>&nbsp;</p>
                      Set</button>     
                  </ion-card>
     </ion-content>

TYPESCRIPT(home.ts):

import { Component } from '@angular/core';
import { NavController,Platform } from 'ionic-angular';

declare var cordova: any;
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController, public platform: Platform) {
  }

  setWall() {
    this.platform.ready().then(() => {
        var setImg = "Cloudinary link";
        cordova.plugins.wallpaper.setImageHttp(setImg, function(error) {
          if (error) {
              console.error(error);
          } else {
              console.log('Success setting wallpaper.');
          }
      });
    });
}
}

I cannot seem to use window.plugins.wallpaper.setImageHttp(link) because it shows " 'Error' message: 'Property 'plugins' does not exist on type 'Window'." Also shows "Runtime Error Uncaught (in promise): TypeError: Cannot read property 'wallpaper' of undefined TypeError: Cannot read property 'wallpaper' of undefined".

The Cloudinary link mentioned above use http and also is .jpg format.

When i run ionic app using cordova.plugins.wallpaper.setImageHttp(link) in ionic serve --lab in chrome and hit 'set' button,console in chrome only shows "ERROR Error: Uncaught (in promise): ReferenceError: cordova is not defined ReferenceError: cordova is not defined".Also ,when i run app in android device no response or change from hitting 'set' button.How to solve this?

Thanks.

cybercodewiz avatar Oct 29 '17 17:10 cybercodewiz

Did someone solved the problem, I'm also facing this issue.

Hammad6264 avatar Nov 05 '19 06:11 Hammad6264