|
1 | 1 | ---
|
2 | 2 | id: alertios
|
3 |
| -title: '🚧 AlertIOS' |
| 3 | +title: '❌ AlertIOS' |
4 | 4 | ---
|
5 | 5 |
|
6 |
| -> **Removed.** Use [`Alert`](alert) instead. |
7 |
| -
|
8 |
| -`AlertIOS` provides functionality to create an iOS alert dialog with a message or create a prompt for user input. |
9 |
| - |
10 |
| -Creating an iOS alert: |
11 |
| - |
12 |
| -```jsx |
13 |
| -AlertIOS.alert( |
14 |
| - 'Sync Complete', |
15 |
| - 'All your data are belong to us.', |
16 |
| -); |
17 |
| -``` |
18 |
| - |
19 |
| -Creating an iOS prompt: |
20 |
| - |
21 |
| -```jsx |
22 |
| -AlertIOS.prompt('Enter a value', null, text => |
23 |
| - console.log('You entered ' + text), |
24 |
| -); |
25 |
| -``` |
26 |
| - |
27 |
| -We recommend using the [`Alert.alert`](alert) method for cross-platform support if you don't need to create iOS-only prompts. |
28 |
| - |
29 |
| ---- |
30 |
| - |
31 |
| -# Reference |
32 |
| - |
33 |
| -## Methods |
34 |
| - |
35 |
| -### `alert()` |
36 |
| - |
37 |
| -```jsx |
38 |
| -static alert(title: string, [message]: string, [callbackOrButtons]: ?(() => void), ButtonsArray, [type]: AlertType): [object Object] |
39 |
| -``` |
40 |
| - |
41 |
| -Create and display a popup alert. |
42 |
| - |
43 |
| -**Parameters:** |
44 |
| - |
45 |
| -| Name | Type | Required | Description | |
46 |
| -| ----------------- | --------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
47 |
| -| title | string | Yes | The dialog's title. Passing null or '' will hide the title. | |
48 |
| -| message | string | No | An optional message that appears below the dialog's title. | |
49 |
| -| callbackOrButtons | ?(() => void),[ButtonsArray](alertios#buttonsarray) | No | This optional argument should be either a single-argument function or an array of buttons. If passed a function, it will be called when the user taps 'OK'. If passed an array of button configurations, each button should include a `text` key, as well as optional `onPress` and `style` keys. `style` should be one of 'default', 'cancel' or 'destructive'. | |
50 |
| -| type | [AlertType](alertios#alerttype) | No | Deprecated, do not use. | |
51 |
| - |
52 |
| -Example with custom buttons: |
53 |
| - |
54 |
| -```jsx |
55 |
| -AlertIOS.alert( |
56 |
| - 'Update available', |
57 |
| - 'Keep your app up to date to enjoy the latest features', |
58 |
| - [ |
59 |
| - { |
60 |
| - text: 'Cancel', |
61 |
| - onPress: () => console.log('Cancel Pressed'), |
62 |
| - style: 'cancel', |
63 |
| - }, |
64 |
| - { |
65 |
| - text: 'Install', |
66 |
| - onPress: () => console.log('Install Pressed'), |
67 |
| - }, |
68 |
| - ], |
69 |
| -); |
70 |
| -``` |
71 |
| - |
72 |
| ---- |
73 |
| - |
74 |
| -### `prompt()` |
75 |
| - |
76 |
| -```jsx |
77 |
| -static prompt(title: string, [message]: string, [callbackOrButtons]: ?((text: string) => void), ButtonsArray, [type]: AlertType, [defaultValue]: string, [keyboardType]: string): [object Object] |
78 |
| -``` |
79 |
| - |
80 |
| -Create and display a prompt to enter some text. |
81 |
| - |
82 |
| -**Parameters:** |
83 |
| - |
84 |
| -| Name | Type | Required | Description | |
85 |
| -| ----------------- | --------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
86 |
| -| title | string | Yes | The dialog's title. | |
87 |
| -| message | string | No | An optional message that appears above the text input. | |
88 |
| -| callbackOrButtons | ?((text: string) => void),[ButtonsArray](alertios#buttonsarray) | No | This optional argument should be either a single-argument function or an array of buttons. If passed a function, it will be called with the prompt's value when the user taps 'OK'. If passed an array of button configurations, each button should include a `text` key, as well as optional `onPress` and `style` keys (see example). `style` should be one of 'default', 'cancel' or 'destructive'. | |
89 |
| -| type | [AlertType](alertios#alerttype) | No | This configures the text input. One of 'plain-text', 'secure-text' or 'login-password'. | |
90 |
| -| defaultValue | string | No | The default text in text input. | |
91 |
| -| keyboardType | string | No | The keyboard type of first text field(if exists). One of 'default', 'email-address', 'numeric', 'phone-pad', 'ascii-capable', 'numbers-and-punctuation', 'url', 'number-pad', 'name-phone-pad', 'decimal-pad', 'twitter' or 'web-search'. | |
92 |
| - |
93 |
| -Example with custom buttons: |
94 |
| - |
95 |
| -```jsx |
96 |
| -AlertIOS.prompt( |
97 |
| - 'Enter password', |
98 |
| - 'Enter your password to claim your $1.5B in lottery winnings', |
99 |
| - [ |
100 |
| - { |
101 |
| - text: 'Cancel', |
102 |
| - onPress: () => console.log('Cancel Pressed'), |
103 |
| - style: 'cancel', |
104 |
| - }, |
105 |
| - { |
106 |
| - text: 'OK', |
107 |
| - onPress: password => |
108 |
| - console.log('OK Pressed, password: ' + password), |
109 |
| - }, |
110 |
| - ], |
111 |
| - 'secure-text', |
112 |
| -); |
113 |
| -``` |
114 |
| - |
115 |
| -, |
116 |
| - |
117 |
| -Example with the default button and a custom callback: |
118 |
| - |
119 |
| -```jsx |
120 |
| -AlertIOS.prompt( |
121 |
| - 'Update username', |
122 |
| - null, |
123 |
| - text => console.log('Your username is ' + text), |
124 |
| - null, |
125 |
| - 'default', |
126 |
| -); |
127 |
| -``` |
128 |
| - |
129 |
| -## Type Definitions |
130 |
| - |
131 |
| -### AlertType |
132 |
| - |
133 |
| -An Alert button type |
134 |
| - |
135 |
| -| Type | |
136 |
| -| ----- | |
137 |
| -| $Enum | |
138 |
| - |
139 |
| -**Constants:** |
140 |
| - |
141 |
| -| Value | Description | |
142 |
| -| -------------- | ---------------------------- | |
143 |
| -| default | Default alert with no inputs | |
144 |
| -| plain-text | Plain text input alert | |
145 |
| -| secure-text | Secure text input alert | |
146 |
| -| login-password | Login and password alert | |
147 |
| - |
148 |
| ---- |
149 |
| - |
150 |
| -### AlertButtonStyle |
151 |
| - |
152 |
| -An Alert button style |
153 |
| - |
154 |
| -| Type | |
155 |
| -| ----- | |
156 |
| -| $Enum | |
157 |
| - |
158 |
| -**Constants:** |
159 |
| - |
160 |
| -| Value | Description | |
161 |
| -| ----------- | ------------------------ | |
162 |
| -| default | Default button style | |
163 |
| -| cancel | Cancel button style | |
164 |
| -| destructive | Destructive button style | |
165 |
| - |
166 |
| ---- |
167 |
| - |
168 |
| -### ButtonsArray |
169 |
| - |
170 |
| -Array or buttons |
171 |
| - |
172 |
| -| Type | |
173 |
| -| ----- | |
174 |
| -| Array | |
175 |
| - |
176 |
| -**Properties:** |
177 |
| - |
178 |
| -| Name | Type | Description | |
179 |
| -| --------- | --------------------------------------------- | ------------------------------------- | |
180 |
| -| [text] | string | Button label | |
181 |
| -| [onPress] | function | Callback function when button pressed | |
182 |
| -| [style] | [AlertButtonStyle](alertios#alertbuttonstyle) | Button style | |
183 |
| - |
184 |
| -**Constants:** |
185 |
| - |
186 |
| -| Value | Description | |
187 |
| -| ------- | ------------------------------------- | |
188 |
| -| text | Button label | |
189 |
| -| onPress | Callback function when button pressed | |
190 |
| -| style | Button style | |
| 6 | +:::danger Removed from React Native |
| 7 | +Use [`Alert`](alert) instead. |
| 8 | +::: |
0 commit comments