Skip to content

Commit 439c28f

Browse files
authored
feature/update docs with linking (#33)
feature/update docs with linking
2 parents a832a5e + ed15218 commit 439c28f

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

README.md

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,51 @@
1-
# `@react-native-community/push-notification-ios`
1+
# @react-native-community/push-notification-ios
22

33
[![Lean Core Extracted](https://img.shields.io/badge/Lean%20Core-Extracted-brightgreen.svg)][lean-core-issue]
44

55
React Native Push Notification API for iOS.
66

77
## Getting started
8-
Install the library using either Yarn:
8+
9+
### Install
910

1011
```
1112
yarn add @react-native-community/push-notification-ios
1213
```
1314

14-
or npm:
15+
### Link
16+
There are a couple of cases for linking. Choose the appropriate one.
17+
- `react-native >= 0.60`
1518

19+
The package is [automatically linked](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) when building the app. All you need to do is:
1620
```
17-
npm install --save @react-native-community/push-notification-ios
21+
cd ios && pod install
1822
```
1923

20-
You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:
21-
24+
- `react-native <= 0.59`
2225
```
2326
react-native link @react-native-community/push-notification-ios
2427
```
2528

26-
<details>
27-
<summary>Manually link the library</summary>
28-
29-
- Add the following to your Project: `node_modules/@react-native-community/push-notification-ios/ios/PushNotificationIOS.xcodeproj`
30-
- Add the following to Link Binary With Libraries: `libRNCPushNotificationIOS.a`
31-
</details>
29+
- upgrading to `react-native >= 0.60`
3230

33-
Finally, to enable support for `notification` and `register` events you need to augment your AppDelegate.
31+
First, unlink the library. Then follow the instructions above.
32+
```
33+
react-native unlink @react-native-community/push-notification-ios
34+
```
35+
36+
- manual linking
3437

35-
#### `AppDelegate.m`
38+
If you don't want to use the methods above, you can always [link the library manually](./docs/manual-linking.md).
3639

37-
- `#import <RNCPushNotificationIOS.h>`
40+
### Update `AppDelegate.m`
3841

42+
Finally, to enable support for `notification` and `register` events you need to augment your AppDelegate.
43+
44+
At the top of the file:
45+
```
46+
#import <RNCPushNotificationIOS.h>
47+
```
48+
Then, add the following lines:
3949
```objective-c
4050
// Required to register for notifications
4151
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
@@ -68,13 +78,13 @@ fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
6878
## Migrating from the core `react-native` module
6979
This module was created when the PushNotificationIOS was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change you imports from:
7080

71-
```javascript
81+
```js
7282
import { PushNotificationIOS } from "react-native";
7383
```
7484

7585
to:
7686

77-
```javascript
87+
```js
7888
import PushNotificationIOS from "@react-native-community/push-notification-ios";
7989
```
8090

docs/manual-linking.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Manual linking
2+
3+
- Add the `.xcodeproj` to your project
4+
```
5+
node_modules/@react-native-community/push-notification-ios/ios/PushNotificationIOS.xcodeproj
6+
```
7+
8+
- Add the following to `Link Binary With Libraries` phase
9+
```
10+
libRNCPushNotificationIOS.a
11+
```
12+
13+
More info on manual linking, [here](https://facebook.github.io/react-native/docs/linking-libraries-ios).

0 commit comments

Comments
 (0)