Native transfer plugin - not available after insta

2019-02-19 15:06发布

I have installed native TRANSFER plugin in my ionic 2 app in 2 steps:
1. ionic plugin add cordova-plugin-file-transfer
2. npm install --save @ionic-native/transfer

After that i imported the plugin in my home.ts page.
Import { Transfer } from '@ionic-native/transfer'

I tried to use the plugin to upload a file var ft = new Transfer();

But i can't use ft var, because Transfer plugin look like it's not avalable. If i write ft.upload () i receive an error like: Property 'upload' does not exist on type 'Transfer'.

My technologies:
Cordova CLI: 6.4.0
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4

In the previous version of my app when using Ionic Framework Version: 2.0.0-rc.5 /Ionic App Scripts Version: 1.0.0 all worked just fine.

Does anyone has any solution for this? Thanks in advance.

标签: ionic2
1条回答
来,给爷笑一个
2楼-- · 2019-02-19 15:54

In the 3.1.0 version of Ionic Native, you have to use the plugin like a provider.

  1. Import it in app.module.ts and set as provider

     import {Transfer} from '@ionic-native/transfer'
    
     @ngModule({
       //...
       providers:[
           Transfer,
           ..]
    
  2. Inject in the component/provider where you need to use it.

    constructor(private fileTransfer:Transfer){}
    
  3. Use the fileTransfer object.

Documentation: Ionic Native and Transfer

查看更多
登录 后发表回答