Navigation

    Monaca & Onsen UI
    • Register
    • Login
    • Search
    • Tags
    • Users
    • Blog
    • Playground
    1. Home
    2. Ahmed Elshorbagy
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    Ahmed Elshorbagy

    @Ahmed Elshorbagy

    0
    Reputation
    53
    Posts
    2432
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online
    Website www.linkedin.com/in/ahmedelshorbagy/ Location Lithuania

    Ahmed Elshorbagy Follow

    Posts made by Ahmed Elshorbagy

    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      Yes

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      I installed an apk on my phone directly, I attached the device to my PC to inspect the errors through chrome

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      I installed a debug version of the app and test it on my phone and used chrome inspect tool to see any errors on the inspection tool on chrome on my PC

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      No. I debug on my pc

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      @khemry no, I created an app with visual studio and installed it on phone but I was debugging it on chrome

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      Yes, is that wrong?

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      any ideas?

      posted in Monaca Tools
      Ahmed Elshorbagy
    • Cannot read property 'getLoginStatus' of undefined at CheckLoginStatus (app.js:19)

      Hello,
      I implemented Monaca Facebook login example in my app and I got this error when I run it on my android phone:
      app.js:19 Uncaught (in promise) TypeError: Cannot read property ‘getLoginStatus’ of undefined
      at CheckLoginStatus (app.js:19)
      at app.js:35
      at Object.ons.ready (onsenui.min.js:6)
      at Object.<anonymous> (app.js:34)
      at Object.invoke (angular.min.js:sourcemap:41)
      at S.instance (angular.min.js:sourcemap:89)
      at p (angular.min.js:sourcemap:65)
      at g (angular.min.js:sourcemap:58)
      at angular.min.js:sourcemap:58
      at Class._compileAndLink (angular-onsenui.min.js:2)

      posted in Monaca Tools
      Ahmed Elshorbagy
    • RE: Onsen Error home.html does not exist

      I fixed that. Thank you

      posted in Onsen UI
      Ahmed Elshorbagy
    • Onsen Error home.html does not exist

      Hello,

      I’m trying to implement Facebook login into my application, I’m using the Monaca example. The example working fine when I install it on my phone. But when I copy the code in my project I get these errors:

      Uncaught Error: The page is not found: home.html
      at XMLHttpRequest.xhr.onerror (onsenui.min.js:5)
      at onsenui.min.js:5
      at onsenui.min.js:5
      at onsenui.min.js:3
      at runIfPresent (onsenui.min.js:3)
      at onGlobalMessage (onsenui.min.js:3)

      My code:
      Index.html

      <!DOCTYPE HTML>
      <html>
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta http-equiv="Content-Security-Policy" content="default-src * data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
        <script src="components/loader.js"></script>
        <script src="lib/angular/angular.min.js"></script>
        <script src="lib/onsenui/js/onsenui.min.js"></script>
        <script src="lib/onsenui/js/angular-onsenui.min.js"></script>
        <script src="js/app.js"></script>
      
        <link rel="stylesheet" href="components/loader.css">
        <link rel="stylesheet" href="lib/onsenui/css/onsenui.css">
        <link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css">
        <link rel="stylesheet" href="css/style.css">
      </head>
      <body>
          <body >
              <ons-navigator id="myNavigator" page="home.html"></ons-navigator>
          </body>
      </body>
      </html>
      

      Hom.hml

      <ons-page ng-controller="HomeCtrl">
          <ons-toolbar>
              <div class="center">Facebook Demo</div>
          </ons-toolbar>
          <div class="page">
              <p class="center">
                  Welcome to Facebook Authentication Demo with Monaca using Onsen UI and AngularJS!
              </p>
              <ons-button ng-click="Login()">                    
                  Connect to Facebook
              </ons-button>        
          </div>
      </ons-page>
      

      App.js

      ons.bootstrap()
      .service('StorageService', function() {    
          var setLoginUser = function(user_info) {
              window.localStorage.login_user = JSON.stringify(user_info);
          };
      
          var getLoginUser = function(){
              return JSON.parse(window.localStorage.login_user || '{}');
          };
      
          return {
              getLoginUser: getLoginUser,
              setLoginUser: setLoginUser
          };
      })
      
      .controller('HomeCtrl', function($scope, StorageService, $http, $q) {
          var CheckLoginStatus = function(){
              window.facebookConnectPlugin.getLoginStatus(
                  function(data){
                      if(data.authResponse){
                          console.log('Login info is found!');
                          myNavigator.pushPage('profile.html');
                      }else{
                          console.log('No login info is found!');
                      }
                  },
                  function(e){
                      LoginError(e);
                  }
              );
          }
          
          ons.ready(function() {
              CheckLoginStatus();
          });
          
          var GetProfileInfo = function (authResponse) {
              var info = $q.defer();
          
              facebookConnectPlugin.api('/me?fields=email,name&access_token=' + authResponse.accessToken, null,
                  function (response) {
                      info.resolve(response);
                  },
                  function (response) {
                      info.reject(response);
                  }
              );
              return info.promise;
          };
          
          var LoginSuccess = function(response){
              var authResponse = response.authResponse;
              
              GetProfileInfo(authResponse).then(function(user) {
                  StorageService.setLoginUser({
                      name: user.name,
                      id: user.id,
                      email: user.email,
                      profile_url: "http://graph.facebook.com/" + authResponse.userID + "/picture?type=large"
                  });
                  myNavigator.pushPage('profile.html');
              }, function(error){
                  console.log('Error retrieving user profile' + JSON.stringify(error));
              });
              
          };
          
          var LoginError = function(error){
              console.log('Login Error: ' + JSON.stringify(error));
              // When "User cancelled dialog" error appears
              if (error.errorCode === "4201"){
                  CheckLoginStatus();
              }
          };
          
          $scope.Login = function(){
              facebookConnectPlugin.login(['email', 'public_profile'], LoginSuccess, LoginError);
          }
          
          
      })
      .controller('ProfileCtrl', function($scope, StorageService, $http, $q) {
          $scope.user = StorageService.getLoginUser();
          
          var LogoutFromFacebook = function(){
              facebookConnectPlugin.logout(
                  function() {
                      console.log('Successful logout!');
                      myNavigator.pushPage("home.html");
                  },
                  function(error) {
                      console.log('Error logging out: ' + JSON.stringify(error));
                  }
              );
          }
          
          $scope.Logout = function(){
              ons.notification.confirm({
                  message: "Are you sure you want to log out?",
                  title: 'Facebook Demo',
                  buttonLabels: ["Yes", "No"],
                  callback: function(idx) {
                  switch (idx) {
                      case 0:
                          LogoutFromFacebook();
                      case 1:
                          break;
                      break;
                  }
                }
              });
          }
      });
      
      posted in Onsen UI
      Ahmed Elshorbagy