How to do it...

  1. We'll start by opening the iOS Project in Xcode, located in the ios directory of the new React Native app.
  2. Let's add a new Cocoa class file named BackgroundTaskManager of subclass NSObject. Refer to the Exposing Custom iOS Modules recipe in this chapter for more details on doing this in Xcode.
  3. Next, lets wire the new module to the React RCTBrideModule in the new module's header file, BackgroundTaskManager.h. The code to be added is marked in bold in the following snippet:
#import <Foundation/Foundation.h>#import <dispatch/dispatch.h>#import "RCTBridgeModule.h"@interface BackgroundTaskManager : NSObject <RCTBridgeModule> {  dispatch_queue_t backgroundQueue;}@end
  1. We'll implement the native module in the BackgroundTaskManager.m ...

Get React Native Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.