Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ios magic links handling #1034

Merged
merged 6 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def DEFAULT_TARGET_SDK_VERSION = 28
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
namespace 'com.auth0.react'

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
Expand Down
20 changes: 5 additions & 15 deletions src/webauth/__tests__/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,10 @@ describe('Agent', () => {
});
});

describe('handle app linking for SFSafariViewController', () => {
it('with useSFSafariViewController AppLinking should be enabled', async () => {
await agent.login({}, { safariViewControllerPresentationStyle: 0 });
expect(Linking.addEventListener).toHaveBeenCalledTimes(1);
});

it('without useSFSafariViewController AppLinking should be enabled', async () => {
await agent.login({}, {});
expect(Linking.addEventListener).toHaveBeenCalledTimes(0);
});

describe('handle app linking for ios platform', () => {
it('for only iOS platform AppLinking should be enabled', async () => {
Platform.OS = 'android';
await agent.login({}, { safariViewControllerPresentationStyle: 0 });
await agent.login({}, {});
expect(Linking.addEventListener).toHaveBeenCalledTimes(0);
Platform.OS = 'ios'; //reset value to ios
});
Expand All @@ -341,7 +331,7 @@ describe('Agent', () => {
try {
await agent.login({}, { safariViewControllerPresentationStyle: 0 });
pmathew92 marked this conversation as resolved.
Show resolved Hide resolved
} catch (e) {}
expect(Linking.addEventListener).toHaveBeenCalledTimes(1);
!expect(Linking.addEventListener).toHaveBeenCalled;
expect(mockSubscription.remove).toHaveBeenCalledTimes(1);
});

Expand Down Expand Up @@ -393,8 +383,8 @@ describe('Agent', () => {
try {
await agent.login({}, {});
} catch (e) {}
expect(Linking.addEventListener).toHaveBeenCalledTimes(0);
expect(mockSubscription.remove).toHaveBeenCalledTimes(0);
!expect(Linking.addEventListener).toHaveBeenCalled();
!expect(mockSubscription.remove).toHaveBeenCalled();
});
});
});
5 changes: 1 addition & 4 deletions src/webauth/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ class Agent {
);
}
return new Promise(async (resolve, reject) => {
if (
Platform.OS === 'ios' &&
options.safariViewControllerPresentationStyle !== undefined
) {
if (Platform.OS === 'ios') {
linkSubscription = Linking.addEventListener('url', async (event) => {
try {
linkSubscription?.remove();
Expand Down
Loading