當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript native-storage.NativeStorage類代碼示例

本文整理匯總了TypeScript中@ionic-native/native-storage.NativeStorage的典型用法代碼示例。如果您正苦於以下問題:TypeScript NativeStorage類的具體用法?TypeScript NativeStorage怎麽用?TypeScript NativeStorage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NativeStorage類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 this.serverProvider.post(this.storageProvider.serverAddress+"/preventMultiLogin",body).then((res:any)=>{
     console.log("res:"+JSON.stringify(res));
     if(res.result=="success"){
       // move into TabPage
       if(res.userInfo.hasOwnProperty("shopList")){
           this.storageProvider.shoplistSet(JSON.parse(res.userInfo.shopList));
       }
       //save this.storageProvider.id
       this.storageProvider.userInfoSetFromServer(res.userInfo);
       //save id information into storage
       let id=this.navParams.get("id");
       if(id!=undefined){
             var encrypted:string=this.storageProvider.encryptValue('id',id);
             this.nativeStorage.setItem('id',encodeURI(encrypted));
             this.storageProvider.id=id;
       }else{
         //read id info and then save it into storageProvider
         this.nativeStorage.getItem("id").then((value:string)=>{
           this.storageProvider.id=this.storageProvider.decryptValue("id",decodeURI(value));
         });
       }
       console.log("move into TbasPage");
       this.app.getRootNav().setRoot(TabsPage);
     }else{
          console.log("move into LoginPage");
           // move into loginPage
           this.storageProvider.reset();
           this.app.getRootNav().setRoot(LoginPage);
     }
 });
開發者ID:raceyi,項目名稱:takit,代碼行數:30,代碼來源:multilogin.ts

示例2: loginUser

  loginUser(){
    console.log("Username:" + this.loginForm.value.username);
    console.log("Password:" + this.loginForm.value.password);
    
    this.nativeStorage.getItem(this.loginForm.value.username).then(
      user => {
        console.log("logged in user:  "+JSON.stringify(user));
        
        if(this.loginForm.value.password===user.password){
          console.log("storing in localstorage: "+user.username)
          this.storage.set("username",user.username).then((username)=>{
            console.log("stored in local: "+username);
            this.storage.set("loggedIn",true).then((loggedIn)=>{
              console.log("loggeado "+loggedIn);
            });
            this.navCtrl.setRoot(ProfilePage);
          });
          
        }else{
          let alert =this.alertCtrl.create({
            title:"Incorrect password",
            buttons:['OK']
          });
          alert.present();

          
        }
      }, error => console.error(error)
    );
  }
開發者ID:valeriafernandz,項目名稱:RickAndMortyApp,代碼行數:30,代碼來源:login.ts

示例3:

 this.storage.get("username").then((username)=>{
   let index= this.favorites.findIndex((favorite)=>favorite.id==id);
   this.favorites.splice(index,1);
   this.nativeStorage.getItem(username).then((user)=>{
     user.favorites=this.favorites;
     this.nativeStorage.setItem(user.username,user).then(()=>{
               console.log("deleted favorite")
     },error=>{console.error("error en set item")})
   })
 })
開發者ID:valeriafernandz,項目名稱:RickAndMortyApp,代碼行數:10,代碼來源:favorites.ts

示例4: if

 this.serverSecretSubmit().then((res:any)=>{
                           console.log("secretSubmit "+JSON.stringify(res));
                           if(res.result=="success"){
                               if(this.id.startsWith("facebook_")){
                                   var encrypted:string=this.storageProvider.encryptValue('id','facebook');
                                   this.nativeStorage.setItem('id',encodeURI(encrypted));
                               }else if(this.id.startsWith("kakao_")){    
                                   var encrypted:string=this.storageProvider.encryptValue('id','kakao');
                                   this.nativeStorage.setItem('id',encodeURI(encrypted));
                               }
                               this.shoplistHandler(res.shopUserInfo);
                           }else if(res.result=='invalidId'){
                               console.log("You have no right to access this app");
                               //this.storageProvider.errorReasonSet('접근권한이 없습니다.');
                               this.navController.setRoot(ErrorPage);
                           }else{
                               console.log("invalid result comes from server-"+JSON.stringify(res));
                               //this.storageProvider.errorReasonSet('서버로 부터 알수 없는 응답을 받았습니다.');
                               this.navController.setRoot(ErrorPage);
                           }
 },(err)=>{
開發者ID:raceyi,項目名稱:takit,代碼行數:21,代碼來源:usersecret.ts

示例5: Promise

 return new Promise((resolve,reject)=>{
   console.log("[loginAgain] id:"+this.storageProvider.id);
           if(this.storageProvider.id=="facebook"){
               this.fbProvider.login().then((res:any)=>{
                           if(res.result=="success"){
                               if(parseFloat(res.version)>parseFloat(this.storageProvider.version)){
                                   console.log("post invalid version");
                                   this.storageProvider.tabMessageEmitter.emit("invalidVersion");
                               }
                               resolve();
                           }else
                               reject("HttpFailure");
                       },login_err =>{
                           reject("NetworkFailure");
               });
           }else if(this.storageProvider.id=="kakao"){ //kakao login
                   console.log("kakao login is not implemented yet");
                   this.kakaoProvider.login().then((res:any)=>{
                           console.log("MyApp:"+JSON.stringify(res));
                           if(res.result=="success"){
                               if(parseFloat(res.version)>parseFloat(this.storageProvider.version)){
                                   console.log("post invalid version");
                                   this.storageProvider.tabMessageEmitter.emit("invalidVersion");
                               }
                               resolve();
                               //save shoplist
                               resolve();
                           }else
                               reject("HttpFailure");
                       },login_err =>{
                               reject("NetworkFailure");
               });
           }else{ // email login 
               this.nativeStorage.getItem("password").then((value:string)=>{
                   var password=this.storageProvider.decryptValue("password",decodeURI(value));
                   this.emailProvider.EmailServerLogin(this.storageProvider.id,password).then((res:any)=>{
                           console.log("MyApp:"+JSON.stringify(res));
                           if(res.result=="success"){
                               if(parseFloat(res.version)>parseFloat(this.storageProvider.version)){
                                   console.log("post invalid version");
                                   this.storageProvider.tabMessageEmitter.emit("invalidVersion");
                               }
                               resolve();
                           }else
                               reject("HttpFailure");
                       },login_err =>{
                               reject("NetworkFailure");
                   });
               });
           }
   });
開發者ID:raceyi,項目名稱:takit,代碼行數:51,代碼來源:serverProvider.ts

示例6: tryLogin

 tryLogin(event){
     if(this.storageProvider.id==undefined){
             this.nativeStorage.getItem("id").then((value:string)=>{
                     console.log("value:"+value);
                     if(value==null){
                         console.log("id doesn't exist");
                         this.app.getRootNav().setRoot(LoginPage); 
                         return;
                     }else{
                         var id=this.storageProvider.decryptValue("id",decodeURI(value));
                         console.log("id:"+id);
                         this.loginWithExistingId();
                     }
             });        
     }else{
         this.loginWithExistingId();
     }
 }
開發者ID:raceyi,項目名稱:takit,代碼行數:18,代碼來源:error.ts

示例7: loginWithExistingId

 loginWithExistingId(){
             var id=this.storageProvider.id;
             if(id=="facebook"){
                 this.fbProvider.login().then((res:any)=>{
                             console.log("MyApp:"+JSON.stringify(res));
                             if(res.result=="success"){
                                 //save shoplist
                                 console.log("res.email:"+res.email +"res.name:"+res.name);
                                 if(res.userInfo.hasOwnProperty("shopList")){
                                     this.storageProvider.shoplistSet(JSON.parse(res.userInfo.shopList));
                                 }
                                 this.storageProvider.emailLogin=false;
                                 this.storageProvider.userInfoSetFromServer(res.userInfo);
                                 console.log("shoplist...:"+JSON.stringify(this.storageProvider.shoplist));
                                 this.app.getRootNav().setRoot(TabsPage);
                             }else if(res.result=='failure' && res.result=='invalidId'){
                                 console.log("사용자 정보에 문제가 발생했습니다. 로그인 페이지로 이동합니다.");
                                 this.app.getRootNav().setRoot(LoginPage);   
                             }else if(res.result=='failure'&& res.error=='multiLogin'){
                                     // How to show user a message here? move into error page?
                                     // Is it possible to show alert here?
                                 this.app.getRootNav().setRoot(MultiloginPage,{id:"facebook"});
                             }else{
                                 console.log("invalid result comes from server-"+JSON.stringify(res));
                                 //this.storageProvider.errorReasonSet('로그인 에러가 발생했습니다');
                                 this.app.getRootNav().setRoot(ErrorPage);   
                             }
                         },login_err =>{
                             console.log("move into ErrorPage-"+JSON.stringify(login_err));
                             //this.storageProvider.errorReasonSet('로그인 에러가 발생했습니다'); 
                             //this.app.getRootNav().setRoot(ErrorPage);
                 });
             }else if(id=="kakao"){ //kakao login
                     //console.log("kakao login is not implemented yet");
                     // read kakao id and try server login
                     this.kakaoProvider.login().then((res:any)=>{
                             console.log("MyApp:"+JSON.stringify(res));
                             if(res.result=="success"){
                                 //save shoplist
                                 if(res.userInfo.hasOwnProperty("shopList")){
                                     this.storageProvider.shoplistSet(JSON.parse(res.userInfo.shopList));
                                 }
                                 this.storageProvider.emailLogin=false;
                                 this.storageProvider.userInfoSetFromServer(res.userInfo);
                                 this.app.getRootNav().setRoot(TabsPage);
                             }else if(res.result=='failure' && res.result=='invalidId'){
                                 console.log("사용자 정보에 문제가 발생했습니다. 로그인 페이지로 이동합니다.");
                                 this.app.getRootNav().setRoot(LoginPage);
                             }else if(res.result=='failure'&& res.error=='multiLogin'){
                                     // How to show user a message here? move into error page?
                                     // Is it possible to show alert here?
                                 this.app.getRootNav().setRoot(MultiloginPage,{id:"kakao"});
                             }else{
                                 console.log("invalid result comes from server-"+JSON.stringify(res));
                                 //this.storageProvider.errorReasonSet('로그인 에러가 발생했습니다');
                                 //this.app.getRootNav().setRoot(ErrorPage);   
                             }
                         },login_err =>{
                             console.log(JSON.stringify(login_err));
                             //this.storageProvider.errorReasonSet('로그인 에러가 발생했습니다'); 
                             //this.app.getRootNav().setRoot(ErrorPage);
                         });
             }else{ // email login 
                     this.nativeStorage.getItem("password").then((value:string)=>{
                     var password=this.storageProvider.decryptValue("password",decodeURI(value));
                     this.emailProvider.EmailServerLogin(id,password).then((res:any)=>{
                             console.log("MyApp:"+JSON.stringify(res));
                             if(res.result=="success"){
                                 if(res.userInfo.hasOwnProperty("shopList")){
                                     //save shoplist
                                     this.storageProvider.shoplistSet(JSON.parse(res.userInfo.shopList));
                                 }
                                 this.storageProvider.emailLogin=true;
                                 this.storageProvider.userInfoSetFromServer(res.userInfo);
                                 this.app.getRootNav().setRoot(TabsPage);
                             }else if(res.result=='failure'&& res.error=='multiLogin'){
                                     // How to show user a message here? move into error page?
                                     // Is it possible to show alert here?
                                 this.app.getRootNav().setRoot(MultiloginPage,{id:id});
                             }else{ 
                                 console.log("사용자 정보에 문제가 발생했습니다. 로그인 페이지로 이동합니다.");
                                 this.app.getRootNav().setRoot(LoginPage);
                             }
                         },login_err =>{
                             console.log(JSON.stringify(login_err));
                             //this.storageProvider.errorReasonSet('로그인 에러가 발생했습니다'); 
                             //this.app.getRootNav().setRoot(ErrorPage);
                     });
                     },(error)=>{
                             console.log("사용자 정보에 문제가 발생했습니다. 로그인 페이지로 이동합니다.");
                             this.app.getRootNav().setRoot(LoginPage);
                     });
             }
 }
開發者ID:raceyi,項目名稱:takit,代碼行數:94,代碼來源:error.ts

示例8:

tokenGetter: (() => nativeStorage.getItem('id_token'))
開發者ID:xinbenlv,項目名稱:rent.zzn.im,代碼行數:1,代碼來源:app.module.ts


注:本文中的@ionic-native/native-storage.NativeStorage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。