fbsanches / cordova-plugin-wallpaper

Cordova Set Wallpaper Plugin
Apache License 2.0
22 stars 17 forks source link

Ionic2 Support? #10

Open MCWiener101 opened 8 years ago

MCWiener101 commented 8 years ago

Hi, does not work out of the box for ionic2 - do I have to follow these instructions? http://www.gajotres.net/ionic-2-how-to-use-cordova-plugins/

Thanks for help! :)

janbaudisch commented 8 years ago

Yes, it should work. Just try it out and let us know about the result.

MCWiener101 commented 8 years ago

Alright, since it's apparently not supported by ionic-native, I did not get it to work yet.

MCWiener101 commented 8 years ago

HI Guys, I did it thanks to this documentation: https://www.thepolyglotdeveloper.com/2016/01/show-native-toast-notifications-in-an-ionic-2-mobile-app/

It was actually pretty easy; one new thing is that you have to put your local images to /src/assets/img and reference them by /assets/img. Good luck!

sajjadalis commented 7 years ago

@sleepybuddha Thanks for sharing that link.

I have tried to reference as /assets/images/ in ionic but its not working.. Tried without beginning slash as well as www/ but none of them is working.

Any suggestion? This is my code.

setWP() {
        this.platform.ready().then(() => {
            var setImg = "/assets/images/wp.jpg";
            window.plugins.wallpaper.setImage(setImg);
        });
    }

I'm using Social-x-Share plugin and that works fine with www/.. like this.

shareWP() {
        this.platform.ready().then(() => {
            var shareImg = "www/assets/images/wp.jpg";
            window.plugins.socialsharing.share(null, null, shareImg, null);
        });
    }

So far i'm stuck at this point in ionic. Would appreciate help.

janbaudisch commented 7 years ago

Please provide some console output (if there is any?), that would help.

sajjadalis commented 7 years ago

Here is the output in console log. /assets/images/wp.jpg home.ts:22

janbaudisch commented 7 years ago

Well, that does not look like an error. You got no further errors?

Did you put your image into /src/assets/{image} and referenced it by /assets/{image} as @sleepybuddha suggested?

sajjadalis commented 7 years ago

Yes. Image is inside /src/assets/images folder. And i tried all possible combinations like

/assets/images/wp.jpg
assets/images/wp.jpg
www/assets/images/wp.jpg
/www/assets/images/wp.jpg
../../assets/images/wp.jpg (just tried this and it shows image loading in home.ts file)

None of them worked so far with ionic.

janbaudisch commented 7 years ago

Then I am out of ideas for now. @sleepybuddha put the images directly into the assets folder (not in the images subfolder), but I don't think this makes a difference.

fbsanches commented 7 years ago

Any News?

MCWiener101 commented 7 years ago

I can not re-verify the folder now since I only used this for testing; I know that I got it to work after some fiddling around. My actual code uses remote URIs and works now with Ionic3 as well; please verify your syntax:

window['plugins'].wallpaper.setImage(remoteImageURI,function() {
        /* Callback does not work yet */
    });

Test App working with this Plugin: https://play.google.com/store/apps/details?id=at.startmeapp.mlp

yaswanthkata commented 7 years ago

How to refer/use this in typescript.could you please provide me an example

yaswanthkata commented 7 years ago

@sleepybuddha I have installed the package ,could you please provide me the usage