-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to use plugin in angular/ionic 2 with types? #2
Comments
You doing it completely right for plugin that supports Ionic2. But Ionic 2 is very very new stuff which requires wrapper for each existing plugin. And such wrapper does not exist yet for my young library.
@Plugin({
name: 'PhotoLibrary',
plugin: 'cordova-plugin-photo-library',
pluginRef: 'cordova.plugins.photoLibrary',
repo: 'https://github.com/terikon/cordova-plugin-photo-library',
platforms: ['Android', 'Browser', 'iOS']
})
export class PhotoLibrary{
// blahblah this should not be complex
} Please try the plugin using window.cordova, and if it will work for your project, I will appreciate an contribution to ionic-native. I myself cannot give you a promise when I will add such wrapper. |
@joshgarwood did you get things working with Ionic 2? For me it only works after sanitizing URL's, see #15 |
Working on this. I have working ionic native wrapper. What's left is documenting it and publishing a PR. |
@viskin how can we import the plugin in ionic 2 ? But I think PhotoLibrary.js is still not complete , right ? Are you following the ionic dev-guideline for the wrapper ? https://github.com/driftyco/ionic-native/blob/master/DEVELOPER.md |
Can't I somehow use the plugin in ionic 2 with typescript till the plugin will be included in ionic-native ? |
I didn't try this (using plain JS mostly), by this file is TypeScript ds file. As far as I understand, you shouldn't do any import. You should make TS compiler see this d.ts file (from tsconfig?), and then definitions will be attached to cordova.plugins.photoLibrary. In theory. |
Maybe adding this to tsconfig.json will work:
|
Added demo project for ionic2 (not yet approved PR). |
Great work! Thank you... Can you take a look at this ? |
no-ionic-native branch contains working typescript version that does not require ionic-native. |
Thank you for doing this! Sadly, Im getting a runtime error after the application is started. (I just downloaded the branch, run on it |
Oops, ionic-native still should be present in package.json. Fixed this. |
Ok, i did give it a try on my iPhone. Its very unresponsive. At the beginning one can scroll just a litttle, but after 5 sec it becomes unresponsive till it crashes. I can see the lists of photos are created (however, without any photos. Photos somehow are not displayed in my iPhone, I dont know why). However, in the iPhone simulator, where I have ca. 10 photos, it seems to work perfectly fine, also the images are correctly shown. |
Well, filling in all the photos to one giant list is not good approach (that's what demo does). Android handles this pretty well, but iOS uses old UIWebView component which is bad. It will be interesting to experiment with new WKWebView which should be more close to Android in terms of performance and reliability. I'll give this a try. |
I tried to install WKWebView and used VirtualScroll. It seems to work well, in my simulator. In my iPhone, its responsive and fast also. It does not hang, it does not crach, scrolling is fine. But in my iPhone 5s, I have the problem of images not showing up, its just the list. Can you test this on your iPhone? I also found this approach http://rintoj.github.io/angular2-virtual-scroll/ Do you think it would be helpfull in our case ? |
Cool, I will try both - WKWebView and angular2-virtual-scroll. |
angular2-virtual-scroll looks very promising, but I could not make it work with ionic in this branch. |
Hi there! I'm really excited to give this plugin a try, but was wondering if you have an example of how to use it with the types you've created? So for instance, would I import something like this:
import PhotoLibraryCorova from 'cordova-plugin-photo-library'
... I tried this and it didn't seem to work, but I'm pretty sure I'm not doing it correctly, ha.
Thanks for your time!
The text was updated successfully, but these errors were encountered: