-
Notifications
You must be signed in to change notification settings - Fork 1
/
facebook.js
35 lines (26 loc) · 1008 Bytes
/
facebook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ANDROID_TARGET, IOS_TARGET } from "../index";
const facebook = (href, target) => {
const pageId = href.split(".com/")[1];
if (target === ANDROID_TARGET) {
return `intent://#Intent;package=com.facebook.katana;scheme=fb://page/${pageId}?referrer=app_link;end`;
} else if (target === IOS_TARGET) {
return `fb://profile/${pageId}`;
}
};
export default facebook;
/* ASYNC VERSION TO GET PAGE ID, MAYBE FUTURE ?
const facebook = async (href, target) => {
const pageName = href.split(".com/")[1];
try {
const pageContent = await axios.get(`https://www.facebook.com/${pageName}`);
const pageId = pageContent.data.match(/"pageID":"([0-9]*)"/)[1];
if (target === ANDROID_TARGET) {
return `intent://#Intent;package=com.facebook.katana;scheme=fb://page/${pageId}?referrer=app_link;end`;
} else if (target === IOS_TARGET) {
return `fb://profile/${pageId}`;
}
} catch (e) {
return "An error happent while getting the facebook page id";
}
};
*/