From 1ee2bbc31f1e8ace5f8176e8675d35b5390a449b Mon Sep 17 00:00:00 2001 From: Calin Tamas Date: Thu, 10 Oct 2019 22:08:14 +0300 Subject: [PATCH 1/2] update docs with linking --- README.md | 48 +++++++++++++++++++++++++----------------- docs/manual-linking.md | 13 ++++++++++++ 2 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 docs/manual-linking.md diff --git a/README.md b/README.md index 9dbe6d789..eb67390ae 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,49 @@ -# `@react-native-community/push-notification-ios` +# @react-native-community/push-notification-ios -React Native Push Notification API for iOS. +React Native Push Notifications 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 +react-native link @react-native-community/async-storage ``` -
-Manually link the library - -- 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` -
+- 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 ` +### 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 +``` +Then, add the following lines: ```objective-c // Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings @@ -66,12 +76,12 @@ 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"; ``` diff --git a/docs/manual-linking.md b/docs/manual-linking.md new file mode 100644 index 000000000..6cdad5e51 --- /dev/null +++ b/docs/manual-linking.md @@ -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). From 7c5b4e6499ac3814f91163ad24435b400bea7b4e Mon Sep 17 00:00:00 2001 From: Calin Tamas Date: Mon, 9 Dec 2019 16:09:03 +0200 Subject: [PATCH 2/2] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb67390ae..514bc607e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ cd ios && pod install - `react-native <= 0.59` ``` -react-native link @react-native-community/async-storage +react-native link @react-native-community/push-notification-ios ``` - upgrading to `react-native >= 0.60`