-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.js
47 lines (33 loc) · 1.44 KB
/
notification.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
36
37
38
39
40
41
42
43
44
45
46
47
import { Notifications } from "expo";
import * as Permissions from 'expo-permissions'
async function registerForPushNotificationsAsync() {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;
// only ask if permissions have not already been determined, because
// iOS won't necessarily prompt the user a second time.
if (existingStatus !== "granted") {
// Android remote notification permissions are granted during the app
// install, so this will only ask on iOS
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
// Stop here if the user did not grant permissions
if (finalStatus !== "granted") {
// Alert.alert('Please enable notification');
return;
}
// Get the token that uniquely identifies this device
let token = await Notifications.getExpoPushTokenAsync();
var fcm = '' + token;
console.log("*****************"+fcm);
}
const asyncFunc = () => {
return new Promise((resolve, reject) => {
registerForPushNotificationsAsync().then(
resolve("okkkkkk")
)
})
}
export default asyncFunc