-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
133 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { isAndroidApp } from 'cozy-device-helper' | ||
|
||
export const NATIVE_APP_INFOS = { | ||
drive: { | ||
appId: 'io.cozy.drive.mobile', | ||
uri: 'cozydrive://', | ||
name: 'Cozy Drive' | ||
}, | ||
banks: { | ||
appId: isAndroidApp() ? 'io.cozy.banks.mobile' : 'io.cozy.banks', | ||
uri: 'cozybanks://', | ||
name: 'Cozy Banks' | ||
} | ||
} | ||
export const UNIVERSAL_LINK_URL = 'https://links.mycozy.cloud' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import { isAndroidApp } from 'cozy-device-helper' | ||
|
||
export const NATIVE_APP_INFOS = { | ||
drive: { | ||
appId: 'io.cozy.drive.mobile', | ||
uri: 'cozydrive://', | ||
name: 'Cozy Drive' | ||
}, | ||
banks: { | ||
appId: isAndroidApp() ? 'io.cozy.banks.mobile' : 'io.cozy.banks', | ||
uri: 'cozybanks://', | ||
name: 'Cozy Banks' | ||
} | ||
import { UNIVERSAL_LINK_URL } from 'cozy-ui/transpiled/react/AppLinker/native.config.js' | ||
export const getUniversalLinkDomain = () => { | ||
return UNIVERSAL_LINK_URL | ||
} | ||
/* | ||
slug string drive | ||
path : /path/to/view | ||
fallbackUrl: string : https://...mycozy.cloud | ||
*/ | ||
export const generateUniversalLink = ({ slug, nativePath, fallbackUrl }) => { | ||
if (!nativePath.startsWith('/')) nativePath = '/' + nativePath | ||
return ( | ||
getUniversalLinkDomain() + | ||
'/' + | ||
slug + | ||
nativePath + | ||
'&fallback=' + | ||
fallbackUrl | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { generateUniversalLink, getUniversalLinkDomain } from './native' | ||
|
||
describe('native functions', () => { | ||
it('should generate the universalink', () => { | ||
const universalLink = generateUniversalLink({ | ||
slug: 'drive', | ||
nativePath: '/files/1', | ||
fallbackUrl: 'https://drive.cozy.tools/files/1' | ||
}) | ||
const endLink = | ||
getUniversalLinkDomain() + | ||
'/drive/files/1&fallback=https://drive.cozy.tools/files/1' | ||
expect(universalLink).toEqual(endLink) | ||
}) | ||
|
||
it('should generate the universalink for the home of an app', () => { | ||
const universalLink = generateUniversalLink({ | ||
slug: 'drive', | ||
nativePath: '/', | ||
fallbackUrl: 'https://drive.cozy.tools/' | ||
}) | ||
const endLink = | ||
'https://links.mycozy.cloud/drive/&fallback=https://drive.cozy.tools/' | ||
expect(universalLink).toEqual(endLink) | ||
}) | ||
|
||
it('should generate the universalink for the home of an app even if no path', () => { | ||
const universalLink = generateUniversalLink({ | ||
slug: 'drive', | ||
nativePath: '', | ||
fallbackUrl: 'https://drive.cozy.tools/' | ||
}) | ||
const endLink = | ||
getUniversalLinkDomain() + '/drive/&fallback=https://drive.cozy.tools/' | ||
expect(universalLink).toEqual(endLink) | ||
}) | ||
}) |