我刚接触离子角膜,请帮忙。
this.socialSharing.shareViaInstagram('test test', newBase64).then((res) => {
console.log("testvalue=====", res);
}).catch((error) => {
console.log("error value ====", error);
});
答案 0 :(得分:0)
那是因为它没有返回Promise。
shareViaInstagram: (message?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
您需要改为:
const onSuccess = () => console.log("testvalue=====", res);
const onError = (error) => console.log("error value ====", error);
this.socialSharing.shareViaInstagram('test test', newBase64, onSuccess, onError);
答案 1 :(得分:0)
只需将then
更改为subscribe
:
this.socialSharing.shareViaInstagram('test test', newBase64).subscribe(res => {
console.log("testvalue=====", res);
} ,error => {
console.log(error);
};
答案 2 :(得分:0)
从'@ ionic-native / social-sharing'导入{SocialSharing};
您没有正确导入软件包。最后添加ngx
。
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
直接分享到Instagram
shareViaInstagram(message: string, image: string): Promise<any> {
return;
}
或通过应用名称共享
shareVia(
appName: string, // <-- instagram
message: string,
subject?: string,
image?: string,
url?: string
): Promise<any> {
return;
}
您还可以检查是否可以共享到Instagram,请在提供的文档中查找该功能。
答案 3 :(得分:0)
检查是否已导入模块
就我而言:
import { SocialSharing } from '@ionic-native/social-sharing/ngx'