1.0.0 • Published 6 years ago
react-native-apns v1.0.0
react-native-apns
Getting started
$ npm install react-native-apns --save
Mostly automatic installation
$ react-native link react-native-apns
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-apns
and addRNApns.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNApns.a
to your project'sBuild Phases
➜Link Binary With Libraries
- In the AppDelegate.m add following:
#import "RNApns.h"
..... ......
// Required for the register event.
- (void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken { RNApns didRegisterForRemoteNotificationsWithDeviceToken:deviceToken; }
// Required for the registrationError event.
- (void)application:(UIApplication )application didFailToRegisterForRemoteNotificationsWithError:(NSError )error { RNApns didFailToRegisterForRemoteNotificationsWithError:error; }
- Run your project (
Cmd+R
)<
Usage
import RNApns from 'react-native-apns';
// TODO: What to do with the module?
RNApns.getToken().then((token) =>
{
console.log(`token${token}`);
console.log('apns_token_success');
},
(error) =>
{
console.log('apns_token_failed');
console.log(error);
});
1.0.0
6 years ago