我使用Ionic Contacts plugin,并且需要获取联系人列表的照片。它可以在iOS上运行,但不能在Android上运行。
我试图对URL以及所有在互联网上找到的所有内容进行清理,归一化,但是没有任何效果。
这是我的代码:
home.ts
export const getPlacesOnMap = () => {
return dispatch => {
dispatch(authGetToken())
.then(token => {
return fetch("myApp?auth=" + token);
})
.catch(() => {
alert("No valid token found!");
})
.then(res => {
if (res.ok) {
return res.json();
} else {
throw(new Error());
}
})
.then(parsedRes => {
const places = [];
for (let key in parsedRes) {
places.push({
// ...parsedRes[key], // this fetches all the data
latitude: parsedRes[key].location.latitude,
longitude: parsedRes[key].location.longitude,
id: key
});
} console.log(places)
dispatch(mapPlaces(places));
})
.catch(err => {
alert("Oops! Something went wrong, sorry! :/");
console.log(err);
});
};
};
export const mapPlaces = places => {
return {
type: MAP_PLACES,
places: places
};
};
home.html
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);
});
}
我在Chrome检查器中遇到的错误:
<button ion-button (click)="getContacts()">Get contacts</button>
<p>Nom : {{ userName }}</p>
<hr />
<img [src]="userPhoto" style="width: 100px;">
您有什么解决方案吗?谢谢!
答案 0 :(得分:0)
对于那些具有相同错误的人,与webview插件存在冲突,当我删除它时,它会起作用。