Skip to content

Commit 7fb7110

Browse files
committed
Updated README
• Fixed instructions for how to add the OneSignalNotificationServiceExtension for rich notifications
1 parent a33acf2 commit 7fb7110

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,24 @@ android {
210210

211211
_By cancelling, you are telling Xcode to continue debugging your application, instead of debugging just the extension. If you activate by accident, you can always switch back to debug your app in Xcode by selecting your application's target (next to the Play button)_
212212

213+
* Go to your Project Settings and select the `OneSignalNotificationServiceExtension` target.
214+
* Go to `Build Settings` and search for `Header Search Paths`
215+
* Add `$(SRCROOT)/../node_modules/react-native-onesignal/ios` and set it as `recursive`
216+
217+
![image](https://raw.githubusercontent.com/nightsd01/react-native-onesignal/master/images/build-settings-search-paths.png)
218+
219+
* With the `OneSignalNotificationServiceExtension` target still selected, select the `Build Phases` tab in Project Settings
220+
* In `Link Binary with Libraries`, add the following frameworks:
221+
- `UIKit.framework`
222+
- `SystemConfiguration.framework`
223+
- `libRCTOneSignal.a`
224+
225+
![image](https://raw.githubusercontent.com/nightsd01/react-native-onesignal/master/images/linked-libraries.png)
226+
213227
* Open `NotificationServiceExtension.m` or `NotificationService.swift` and replace the whole file contents with the code below:
214228

215229
```objc
216-
#import <OneSignal/OneSignal.h>
230+
#import <RCTOneSignalExtensionService.h>
217231

218232
#import "NotificationService.h"
219233

@@ -232,7 +246,7 @@ _By cancelling, you are telling Xcode to continue debugging your application, in
232246
self.contentHandler = contentHandler;
233247
self.bestAttemptContent = [request.content mutableCopy];
234248

235-
[OneSignal didReceiveNotificationExtensionRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];
249+
[RCTOneSignalExtensionService didReceiveNotificationRequest:self.receivedRequest withContent:self.bestAttemptContent];
236250

237251
// DEBUGGING: Uncomment the 2 lines below and comment out the one above to ensure this extension is excuting
238252
// Note, this extension only runs when mutable-content is set
@@ -247,7 +261,7 @@ _By cancelling, you are telling Xcode to continue debugging your application, in
247261
// Called just before the extension will be terminated by the system.
248262
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
249263

250-
[OneSignal serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];
264+
[RCTOneSignalExtensionService serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent];
251265

252266
self.contentHandler(self.bestAttemptContent);
253267
}
740 KB
Loading

images/linked-libraries.png

328 KB
Loading

0 commit comments

Comments
 (0)