Ionic 3:无法获取联系人照片
Ionic 3: Can't get contacts photos
我使用 Ionic Contacts plugin,我需要获取联系人列表的照片。它在 iOS 中有效,但在 Android 中无效。
我尝试清理、规范化 URL 以及我在互联网上找到的所有内容,但没有任何效果。
这是我的代码:
home.ts
userPhoto: any;
getContacts() {
this.contacts.find(['displayName', 'name', 'phoneNumbers', 'emails', 'photos'], {filter: "", multiple: true})
.then(data => {
console.table(data[0]);
this.userName = data[0].displayName;
this.userPhoto = this.sanitizer.bypassSecurityTrustUrl(data[0].photos[0].value);
});
}
home.html
<button ion-button (click)="getContacts()">Get contacts</button>
<p>Nom : {{ userName }}</p>
<hr />
<img [src]="userPhoto" style="width: 100px;">
我在 Chrome 检查器中遇到的错误:
Not allowed to load local resource: content://com.android.contacts/contacts/1/photo
你有什么解决办法吗?谢谢!
有同样错误的朋友,与webview插件有冲突,我把它去掉后就可以了。
我使用 Ionic Contacts plugin,我需要获取联系人列表的照片。它在 iOS 中有效,但在 Android 中无效。
我尝试清理、规范化 URL 以及我在互联网上找到的所有内容,但没有任何效果。
这是我的代码:
home.ts
userPhoto: any;
getContacts() {
this.contacts.find(['displayName', 'name', 'phoneNumbers', 'emails', 'photos'], {filter: "", multiple: true})
.then(data => {
console.table(data[0]);
this.userName = data[0].displayName;
this.userPhoto = this.sanitizer.bypassSecurityTrustUrl(data[0].photos[0].value);
});
}
home.html
<button ion-button (click)="getContacts()">Get contacts</button>
<p>Nom : {{ userName }}</p>
<hr />
<img [src]="userPhoto" style="width: 100px;">
我在 Chrome 检查器中遇到的错误:
Not allowed to load local resource: content://com.android.contacts/contacts/1/photo
你有什么解决办法吗?谢谢!
有同样错误的朋友,与webview插件有冲突,我把它去掉后就可以了。