Hi, guys, I need help, I can not share the audio file for whatsapp, I do not know what else to do. My code is this:
It simply opens whatsapp I click on the contact to send the file and it returns to my the ionic app and does not send the file to the selected contact
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as SoundboardMap from './../../models/soundboard.mapping';
import { Media, MediaObject } from '@ionic-native/media';
import { SocialSharing } from '@ionic-native/social-sharing';
import { Base64 } from '@ionic-native/base64';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public soundboardData: SoundboardMap.SoundboardMap[];
public soundboardData2: SoundboardMap.SoundboardMap[];
public soundboardData3: SoundboardMap.SoundboardMap[];
public file: MediaObject;
constructor(public navCtrl: NavController, public media: Media, public socialSharing: SocialSharing, public base64: Base64) {
this.soundboardData = SoundboardMap.SoundboardMock;
this.soundboardData2 = SoundboardMap.SoundboardMock2;
this.soundboardData3 = SoundboardMap.SoundboardMock3;
}
public playSound(ressource: string){
if(this.file){
this.file.stop();
this.file.release();
}
this.file = this.media.create('/android_asset/www/assets/' + ressource);
this.file.play();
}
public shareSound(ressource: string){
let filePath: string = '/android_asset/www/assets/' + ressource;
//let filePath: string = 'file://android_asset/www/assets/' + ressource I tried that way too.
this.socialSharing.share(null, null, base64File, null).then(() => {
this.socialSharing.share(base64File).then(() => {
}).catch(() => {
// Error!
});
}, (err) => {
console.log(err);
});
}
}