• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript native-storage.NativeStorage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript network.Network类代码示例发布时间:2022-05-28
下一篇:
TypeScript native-page-transitions.NativePageTransitions类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap