- Let's start by opening the iOS Project in Xcode located in the ios directory of the new React Native app.
- Next, we'll create a new Objective-C Cocoa class called MediaManager.
- In the MediaManager header (.h) file, we need to import MPMediaPickerController and MPMusicPlayerController, along with the React Native bridge (RCTBridgeModule), as follows:
#import <Foundation/Foundation.h>#import <MediaPlayer/MediaPlayer.h>#import <React/RCTBridgeModule.h>#import <React/RCTEventDispatcher.h>@interface MediaManager : NSObject<RCTBridgeModule, MPMediaPickerControllerDelegate>@property (nonatomic, retain) MPMediaPickerController *mediaPicker;@property (nonatomic, retain) MPMusicPlayerController *musicPlayer;@end
- First, we are going ...
Get React Native Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.