Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/update docs with linking #33

Merged
merged 3 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
# `@react-native-community/push-notification-ios`
# @react-native-community/push-notification-ios

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

React Native Push Notification API for iOS.

## Getting started
Install the library using either Yarn:

### Install

```
yarn add @react-native-community/push-notification-ios
```

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

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:
```
npm install --save @react-native-community/push-notification-ios
cd ios && pod install
```

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:

- `react-native <= 0.59`
```
react-native link @react-native-community/push-notification-ios
```

<details>
<summary>Manually link the library</summary>

- Add the following to your Project: `node_modules/@react-native-community/push-notification-ios/ios/PushNotificationIOS.xcodeproj`
- Add the following to Link Binary With Libraries: `libRNCPushNotificationIOS.a`
</details>
- upgrading to `react-native >= 0.60`

Finally, to enable support for `notification` and `register` events you need to augment your AppDelegate.
First, unlink the library. Then follow the instructions above.
```
react-native unlink @react-native-community/push-notification-ios
```

- manual linking

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

- `#import <RNCPushNotificationIOS.h>`
### Update `AppDelegate.m`

Finally, to enable support for `notification` and `register` events you need to augment your AppDelegate.

At the top of the file:
```
#import <RNCPushNotificationIOS.h>
```
Then, add the following lines:
```objective-c
// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
Expand Down Expand Up @@ -68,13 +78,13 @@ fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
## Migrating from the core `react-native` module
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:

```javascript
```js
import { PushNotificationIOS } from "react-native";
```

to:

```javascript
```js
import PushNotificationIOS from "@react-native-community/push-notification-ios";
```

Expand Down
13 changes: 13 additions & 0 deletions docs/manual-linking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Manual linking

- Add the `.xcodeproj` to your project
```
node_modules/@react-native-community/push-notification-ios/ios/PushNotificationIOS.xcodeproj
```

- Add the following to `Link Binary With Libraries` phase
```
libRNCPushNotificationIOS.a
```

More info on manual linking, [here](https://facebook.github.io/react-native/docs/linking-libraries-ios).