Angular Satellizer causing issues with Facebook login on mobile devices

Issue

Currently, I'm developing an application using Angular and have successfully integrated Facebook login through Satellizer. The functionality works flawlessly on desktop browsers; however, when accessed from mobile devices, it tends to be unreliable. In some cases, the login pop-up fails to close, leaving the main screen in a state of limbo where it displays the home page within the login pop-up rather than returning to the original requesting screen. Any insights into what might be causing this inconsistency would be greatly appreciated.

Code Snippet

Snippet showcasing the authentication process with Facebook:

var commonConfig = {
    popupOptions: {
     location: 'no',
     toolbar: 'yes',
     width: window.screen.width,
     height: window.screen.height
   }
};

var permissions = ["public_profile","email"];
$authProvider.facebook(angular.extend({}, commonConfig, {
  clientId: FacebookAppId,
  url: ApiUrl+'api/v1/facebook/auth',
  scope:permissions,
  scopeDelimiter:','
}));

This code block is executed upon clicking "connect using Facebook":

$scope.loginSocial = function () {
    $scope.disableSubmitBtn = true;
    $scope.showSpinner = true;

    $auth.authenticate('facebook')
      .then(function (result) {
        result = angular.fromJson(result.data.code)
        return AuthServerProvider.loginFb(result.facebookCode);
      },function (error) {
        $scope.status = 'facebook-error';
        $scope.disableSubmitBtn = false;
        $scope.showSpinner = false;
      })
      .then(function(){
        $scope.disableSubmitBtn = true;
        $scope.showSpinner = true;
      })

While this code segment functions correctly on desktop browsers, it encounters frequent failures when accessed from mobile browsers during the "$auth.authenticate('facebook')" step.

Answer №1

We encountered a similar issue when working with Satellizer. Our problem stemmed from how the redirectUri was being handled within angular ui.router. Upon revisiting the library documentation, we came across the following advice:

To prevent potential 404 errors, it is recommended to create server routes for each redirectUri URL that return a 200 OK status. Alternatively, you can create a custom template with a loading spinner. Currently, due to a 20ms interval polling, a popup may not stay visible long enough to display the custom template. However, there are plans to allow overriding this polling interval in the future.

In your code snippet above, you did not specify a redirectUri, which means it defaults to '/'. If this route clashes with another route in angular, the redirection may occur before Satellizer has a chance to process it. To avoid this issue, assign a specific redirectUri and handle it through angular routes.

For more information, please take a look at this post.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountered a problem while establishing a connection to Firebase following the upgrade of

Ever since I upgraded angularfire to version 2.0.1 in order to support the latest Firebase version 3.2.0, my app has been unable to establish a connection with the database. I'm not sure what could be causing this issue. Here's the code that used ...

"The orderBy function in AngularJS seems to be overlooked or not functioning properly within the

It seems like the orderBy function is being ignored in my code. Despite adding a console.log for testing purposes, the function doesn't appear to be called at all. As a result, the data is still displayed but remains unordered. Snippet of HTML Code ...

Trouble with REGEX functionality in AngularJS?

I have a code snippet where I am attempting to validate an email and phone number. However, for some reason it is not functioning as expected. I am wondering if there is a specific file that needs to be included in my code. <html ng-app="myApp"> < ...

Can you show me a way to display a dynamically created array component on an Angular2 template html?

One way I've been able to generate dynamic component instances is by choosing from pre-existing components. For instance, @Component({ selector: 'dynamic-component', template: `<div #container><ng-content></ng-conten ...

Ways to share code across AngularJS frontend and Node.js backend

How can code be effectively shared between an AngularJS client and a Node.js server? After creating an AngularJS application, I now need to develop a RESTful server to provide data to the client. Some Angular services used on the client-side could also be ...

What is the technique for hiding the bottom tab navigator upon leaving a specific screen in React Native version 5?

In the home screen, I want only the bottom tab navigator to be visible, and then hidden until the user returns to the home screen. The example provided below is tailored for working in the App.js file, but my situation is different. const Tab = createBot ...

Is there a way to showcase the data of each table row within the tr tag in an Angular 8 application?

I have been developing an application using Angular 8. The employee-list component is responsible for presenting data in a table format. Within the employee-list.component.ts file, I have defined: import { Component } from '@angular/core'; impo ...

Tips for presenting the retrieved data from the database in a user-friendly format

$ //First step involves running the PHP code that executes the SQL query to retrieve data from the database, storing it in get_row1, and sending it as a response to Ajax$ <?php $connect = mysql_connect("localhost", "root", ""); $data = mysq ...

Transforming two child arrays within an object into a single array using Ramda

I am looking to transform an object into an array. The object I have is structured like this: const data = { t1: [ {"a": 1, "a1": 2}, {"b": 3, "b1": 4}, {"c": 5, "c1": 6} ], t2: [ {" ...

React: maintaining referential equality across renders by creating closures with useCallback

I want to make sure the event handling function I create in a custom hook in React remains referentially equal across renders. Is it possible to achieve this using useCallback without specifying any variables it closes over in the dependencies list? Will o ...

What is the best way to implement a tooltip that appears only when the mouse hovers over a button within an item in vis.js timeline?

While working with vis.js timeline, I successfully created a timeline. However, I encountered an issue where the tooltip was appearing on the entire item instead of just when hovering over the button. I tried using the title attribute for the tooltip, bu ...

Another class is overriding the border of the text-box

I'm facing a challenge in customizing the material ui css. Specifically, I want to set the border color of a textbox to red. The issue arises when the bottom border gets overwritten. Upon investigation, I discovered that the culprit is the class MuiIn ...

initialize a while loop in the $scope

Is it possible to create a scope inside a loop similar to JavaScript's var data + [i]? I believe it is, and I want to push some data to the scope in this manner. for (var i = 0; i < $scope.laporanDataKuisioner.contents.length; i++) { ...

Refresh Next.js on Navigation

Is there a way to trigger a reload when clicking on a Link component from next/link? I attempted to create my own function within the child div of the link that would reload upon click. However, it seems to reload before the route changes and is not succ ...

The Chrome browser's memory heap is reported to be a mere 10 MB, yet the task manager displays a whopping

When using Chrome's memory profiler, I notice that the heap size is always around 10 MB. However, the memory in my task manager keeps increasing and can reach over 1 GB if I leave my website running. Even though the heap size remains less than 10 MB w ...

Can you verify the standard behavior when importing index.js using create-react-app?

I'm trying to wrap my head around why, when using create react app, if a folder contains an index.js file and you want to import it, you only need to specify the folder name. I've been wondering where this default behavior is configured to autom ...

I developed an RPG game with an interactive element using jQuery. One of the biggest challenges I'm facing is the random selection process for determining which hero will be targeted by the enemy bots during battles

Hello, this marks my debut on stack overflow with a question. I've created a game inspired by old school RPGs where players choose from three heroes based on the Marvel universe to battle one of three enemies. The problem I'm facing is that even ...

Difficulty encountered when applying a CSS class with JavaScript

The Javascript function I am currently using is able to select multiple links. This behavior occurs because of the Regular expression I applied with the '^' symbol. I decided to use this approach because my links are in the following format: htt ...

Refreshing the Socket.io page causes disconnection from the room

After researching solutions to this issue, none seem to be effective for my specific setup. My setup involves a nodeJS server with express and Socket.io for sending notifications to individual users (Angular on the frontend). Upon login, each user is ass ...

The PageMethods function is successful when using a single parameter, but encounters an error when attempting to use two parameters, resulting in the

PageMethods worked perfectly when sending a single parameter to a code-behind aspx page. However, I encountered the error "Unknown web method" when attempting to provide two parameters (or an Object other than a String). The functional code in my aspx pag ...