forked from revtel/react-native-nfc-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
80 lines (65 loc) · 2 KB
/
index.d.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { EmitterSubscription } from "react-native";
// Type definitions for react-native-nfc-manager
// Project: https://github.com/whitedogg13/react-native-nfc-manager
// Definitions by: April Ayres <[email protected]> and Paul Huynh <[email protected]>
declare module 'react-native-nfc-manager' {
export interface NdefRecord {
id?: number[];
tnf: number;
type: number[];
payload: any[];
}
export interface ParseUriResult {
uri: string;
}
export interface StartOptions {
onSessionClosedIOS(): void;
}
export interface TagEvent {
ndefMessage: NdefRecord[];
maxSize: number;
type: string;
techTypes: string[];
id: number[];
}
interface NdefWriteOpts {
format?: boolean
formatReadOnly?: boolean
}
interface EventStateChange {
state: string
}
interface NfcManager {
start(options?: StartOptions): Promise<any>;
stop(): void;
isSupported(): Promise<boolean>;
/** [ANDROID ONLY] */
isEnabled(): Promise<boolean>;
/** [ANDROID ONLY] */
goToNfcSetting(): Promise<any>;
/** [ANDROID ONLY] */
getLaunchTagEvent(): Promise<TagEvent | null>;
/**
* Start to listen to ANY NFC Tags
* @param listener The callback function when a tag is found.
* @param alertMessage [iOS ONLY] Message displayed when NFC Scanning popup appears.
* @param invalidateAfterFirstRead [iOS ONLY] When set to true, will auto-dismiss the NFC Scanning popup after scanning.
*/
registerTagEvent(
listener: (tag: TagEvent) => void,
alertMessage?: string,
invalidateAfterFirstRead?: boolean
): Promise<any>;
unregisterTagEvent(): Promise<any>;
/* android only */
cancelNdefWrite(): Promise<any>;
requestNdefWrite(bytes: number[], opts?: NdefWriteOpts): Promise<any>;
onStateChanged(listener: (event: EventStateChange) => void): Promise<EmitterSubscription>;
}
const nfcManager: NfcManager;
export namespace NdefParser {
function parseUri(ndef: NdefRecord): ParseUriResult;
function parseText(ndef: NdefRecord): string | null;
}
}
export default nfcManager;