1
私が構築しているアプリケーションがあり、Androidのデバイスでは絶対にうまく動作していますが、iOSでグラフのAPIエラーが表示されます。Ionic cordova-facebook-plugin4がapiグラフコールに失敗する
ここではFacebookのログインに使用しているコードを示します。ここで
constructor(private menuCtrl: MenuController, private nav: NavController, private playerService: Players, private userService: Users, private packService: Packs, private modalCtrl: ModalController, private loadingCtrl: LoadingController) {
Facebook.browserInit(this.FB_APP_ID, "v2.8");
menuCtrl.enable(false, 'navMenu');
}
ionViewLoaded() {
}
doFbLogin() {
var permissions = new Array();
let nav = this.nav;
let userService = this.userService;
let playerService = this.playerService;
let packService = this.packService;
var menuCtrl = this.menuCtrl;
//the permissions your facebook app needs from the user
permissions = ["public_profile", "email", "user_friends"];
Facebook.login(permissions)
.then(function (response) {
let userId = response.authResponse.userID;
//Getting name and gender properties
Facebook.api("me/?fields=name,gender,email,friends", permissions)
.then(function (user) {
user.picture = "https://graph.facebook.com/" + userId + "/picture?type=large";
user.fbid = user.id;
//now we have the users info, let's save it in the NativeStorage
NativeStorage.setItem('user',
{
userid: userId,
name: user.name,
gender: user.gender,
picture: user.picture,
email: user.email,
fbid: user.id
})
.then(function (user) {
console.log("email to check", user.email);
//now we check if there is an existing account with this email address.
userService.accountExists(user.email).then((data) => {
let founduser = data;
if (founduser) {
user = founduser;
console.log("existing user no account created");
menuCtrl.enable(true, 'navMenu');
nav.setRoot(Dashboard);
nav.pop();
nav.push(Dashboard);
} else {
user.wins = 0;
user.draws = 0;
user.losses = 0;
user.authenticated = true;
user.maroon_points = 0;
userService.createUser(user);
var createdUser = {};
//get user id of newly created user from db
userService.accountExists(user.email).then((data) => {
createdUser = { '_id': data._id };
if (createdUser) {
playerService.getStarterPlayers().then((data) => {
var starters = data;
let i = 0;
while (i < _.keys(starters).length) {
let playerObj = {
userid: createdUser['_id'],
playerid: starters[i]._id,
position: starters[i].position
};
console.log("playerObj[" + i + "]", playerObj);
playerService.giveOwnedPlayer(playerObj);
i++
}
});
packService.getStarter().then((data) => {
var packsChosen = data;
let j = 0;
while (j < _.keys(packsChosen).length) {
let packObj = {
_id: packsChosen[j]._id,
owner: createdUser['_id']
};
console.log("packObj[" + j + "]", packObj);
packService.giveSingle(packObj);
j++
}
});
menuCtrl.enable(true, 'navMenu');
nav.setRoot(Dashboard);
nav.pop();
nav.push(Dashboard);
} else {
console.error("NO USER FOUND");
}
});
console.log("no existing user account created!");
}
});
}, function (error) {
console.log(error);
})
})
}, function (error) {
console.log("error - FB graph call failed", error);
});
}
アプリを検査する際サファリWebコンソールにスローされるエラーは問題がXcodeでコードをコンパイルして、他のユーザーだった6
[Error] EXCEPTION: Uncaught (in promise): There was an error making the graph call.
handleError (main.js:81941)
handleError (main.js:152942)
next (main.js:55809:94)
(anonymous function) (main.js:57865)
__tryOrUnsub (main.js:1389)
next (main.js:1338)
_next (main.js:1291)
next (main.js:1255)
next (main.js:7764)
emit (main.js:57851)
triggerError (main.js:41831)
onHandleError (main.js:41792)
runGuarded (polyfills.js:3:7279)
r (polyfills.js:3:3818)
i (polyfills.js:3:3867)
invoke (polyfills.js:3:11439)
(anonymous function) (polyfills.js:2:30199)
[Error] ORIGINAL STACKTRACE:
handleError (main.js:81946)
handleError (main.js:152942)
next (main.js:55809:94)
(anonymous function) (main.js:57865)
__tryOrUnsub (main.js:1389)
next (main.js:1338)
_next (main.js:1291)
next (main.js:1255)
next (main.js:7764)
emit (main.js:57851)
triggerError (main.js:41831)
onHandleError (main.js:41792)
runGuarded (polyfills.js:3:7279)
r (polyfills.js:3:3818)
i (polyfills.js:3:3867)
invoke (polyfills.js:3:11439)
(anonymous function) (polyfills.js:2:30199)
[Error] [email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:4869
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:4298
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:4113
file:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:4653
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:10289
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/main.js:41762:47
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:10232
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:7647
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:3714
[email protected]:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:3:11438
file:///var/containers/Bundle/Application/704E4F8E-C28D-49C9-9393-0CDA54106CAF/Pitchlife.app/www/build/polyfills.js:2:30198
handleError (main.js:81947)
handleError (main.js:152942)
next (main.js:55809:94)
(anonymous function) (main.js:57865)
__tryOrUnsub (main.js:1389)
next (main.js:1338)
_next (main.js:1291)
next (main.js:1255)
next (main.js:7764)
emit (main.js:57851)
triggerError (main.js:41831)
onHandleError (main.js:41792)
runGuarded (polyfills.js:3:7279)
r (polyfills.js:3:3818)
i (polyfills.js:3:3867)
invoke (polyfills.js:3:11439)
(anonymous function) (polyfills.js:2:30199)