i try make user service connect facebook. i've try localstorage plugin, when memory low, ios delete files , cause white screen.
so, now, use cordova file plugin , want implement user service store user datas.
this first app, target ios , android, device iphone 5s, ios 8.3 , develop in macos.
in config.xml, i've :
<preference name="iospersistentfilelocation" value="library"/>
and, user service :
myapp.service('userservice', function($cordovafile) { var setuser = function(user_data) { $cordovafile.writefile(cordova.file.datadirectory, "myapp_user", json.stringify(json), true) } var userisloggedin = function() { var user = getuser() return user && user.authresponse && user.authresponse.userid != null; } var userisnotloggedin = function() { var user = getuser() return user && user.authresponse && user.authresponse.userid == null; } var getuser = function() { return $cordovafile.readastext("myapp_user"); } return { getuser: getuser, setuser: setuser, userisloggedin: userisloggedin, userisnotloggedin: userisnotloggedin } })
in facebook connect, i've recover data (it's work localstorage, problem not here)
userservice.setuser({ authresponse: authresponse, name: profileinfo.name, user_id: profileinfo.id, first_name: profileinfo.first_name, picture: profileinfo.picture.data.url, ionic_id: ionicuser.id })
so, login facebook work charm, when want read json data, can't ! have white screen , error : userid not defined !
can me read json file ?
thanks !
Comments
Post a Comment