Skip to content

Commit aa69af1

Browse files
authored
chore: update example and lint (#137)
1 parent f7dcd57 commit aa69af1

File tree

5 files changed

+130
-104
lines changed

5 files changed

+130
-104
lines changed

example/App.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ export const App = () => {
4545
);
4646

4747
PushNotificationIOS.requestPermissions().then(
48-
data => {
48+
(data) => {
4949
console.log('PushNotificationIOS.requestPermissions', data);
5050
},
51-
data => {
51+
(data) => {
5252
console.log('PushNotificationIOS.requestPermissions failed', data);
5353
},
5454
);
@@ -85,6 +85,7 @@ export const App = () => {
8585

8686
const sendLocalNotification = () => {
8787
PushNotificationIOS.presentLocalNotification({
88+
alertTitle: 'Sample Title',
8889
alertBody: 'Sample local notification',
8990
applicationIconBadgeNumber: 1,
9091
});
@@ -97,7 +98,7 @@ export const App = () => {
9798
});
9899
};
99100

100-
const onRegistered = deviceToken => {
101+
const onRegistered = (deviceToken) => {
101102
Alert.alert('Registered For Remote Push', `Device Token: ${deviceToken}`, [
102103
{
103104
text: 'Dismiss',
@@ -106,7 +107,7 @@ export const App = () => {
106107
]);
107108
};
108109

109-
const onRegistrationError = error => {
110+
const onRegistrationError = (error) => {
110111
Alert.alert(
111112
'Failed To Register For Remote Push',
112113
`Error (${error.code}): ${error.message}`,
@@ -119,7 +120,7 @@ export const App = () => {
119120
);
120121
};
121122

122-
const onRemoteNotification = notification => {
123+
const onRemoteNotification = (notification) => {
123124
const result = `Message: ${notification.getMessage()};\n
124125
badge: ${notification.getBadgeCount()};\n
125126
sound: ${notification.getSound()};\n
@@ -134,7 +135,7 @@ export const App = () => {
134135
]);
135136
};
136137

137-
const onLocalNotification = notification => {
138+
const onLocalNotification = (notification) => {
138139
Alert.alert(
139140
'Local Notification Received',
140141
'Alert message: ' + notification.getMessage(),
@@ -148,7 +149,7 @@ export const App = () => {
148149
};
149150

150151
const showPermissions = () => {
151-
PushNotificationIOS.checkPermissions(permissions => {
152+
PushNotificationIOS.checkPermissions((permissions) => {
152153
setPermissions({permissions});
153154
});
154155
};

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ PODS:
292292
- React-cxxreact (= 0.62.2)
293293
- React-jsi (= 0.62.2)
294294
- ReactCommon/callinvoker (= 0.62.2)
295-
- RNCPushNotificationIOS (1.1.1):
295+
- RNCPushNotificationIOS (1.2.2):
296296
- React
297297
- Yoga (1.14.0)
298298
- YogaKit (1.18.1):
@@ -453,7 +453,7 @@ SPEC CHECKSUMS:
453453
React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d
454454
React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256
455455
ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3
456-
RNCPushNotificationIOS: a0b6894f4ad9b93d9dac467fdf4d055660ac8a0d
456+
RNCPushNotificationIOS: 4c97a36dbec42dba411cc35e6dac25e34a805fde
457457
Yoga: 3ebccbdd559724312790e7742142d062476b698e
458458
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
459459

example/ios/example/AppDelegate.m

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,52 @@
77

88
#import "AppDelegate.h"
99

10+
#import <RNCPushNotificationIOS.h>
1011
#import <React/RCTBridge.h>
1112
#import <React/RCTBundleURLProvider.h>
1213
#import <React/RCTRootView.h>
13-
#import <RNCPushNotificationIOS.h>
14-
#import <UserNotifications/UserNotifications.h>
1514

1615
#if DEBUG
1716
#import <FlipperKit/FlipperClient.h>
1817
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
19-
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
2018
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
21-
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
2219
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
20+
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
21+
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
2322
static void InitializeFlipper(UIApplication *application) {
2423
FlipperClient *client = [FlipperClient sharedClient];
25-
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
26-
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
24+
SKDescriptorMapper *layoutDescriptorMapper =
25+
[[SKDescriptorMapper alloc] initWithDefaults];
26+
[client addPlugin:[[FlipperKitLayoutPlugin alloc]
27+
initWithRootNode:application
28+
withDescriptorMapper:layoutDescriptorMapper]];
2729
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
2830
[client addPlugin:[FlipperKitReactPlugin new]];
29-
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
31+
[client addPlugin:[[FlipperKitNetworkPlugin alloc]
32+
initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
3033
[client start];
3134
}
3235
#endif
3336

3437
@implementation AppDelegate
3538

36-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
37-
{
39+
- (BOOL)application:(UIApplication *)application
40+
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
3841

39-
#if DEBUG
42+
#if DEBUG
4043
InitializeFlipper(application);
41-
#endif
44+
#endif
4245

43-
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
46+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
47+
launchOptions:launchOptions];
4448
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
4549
moduleName:@"example"
4650
initialProperties:nil];
4751

48-
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
52+
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f
53+
green:1.0f
54+
blue:1.0f
55+
alpha:1];
4956

5057
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
5158
UIViewController *rootViewController = [UIViewController new];
@@ -54,59 +61,72 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5461
[self.window makeKeyAndVisible];
5562

5663
// Define UNUserNotificationCenter
57-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
64+
UNUserNotificationCenter *center =
65+
[UNUserNotificationCenter currentNotificationCenter];
5866
center.delegate = self;
5967

6068
return YES;
6169
}
6270

63-
//Called when a notification is delivered to a foreground app.
64-
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
65-
{
66-
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
71+
// Called when a notification is delivered to a foreground app.
72+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
73+
willPresentNotification:(UNNotification *)notification
74+
withCompletionHandler:
75+
(void (^)(UNNotificationPresentationOptions options))
76+
completionHandler {
77+
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert |
78+
UNAuthorizationOptionBadge);
6779
}
6880

6981
// Required to register for notifications
70-
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
71-
{
72-
[RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
82+
- (void)application:(UIApplication *)application
83+
didRegisterUserNotificationSettings:
84+
(UIUserNotificationSettings *)notificationSettings {
85+
[RNCPushNotificationIOS
86+
didRegisterUserNotificationSettings:notificationSettings];
7387
}
7488
// Required for the register event.
75-
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
76-
{
77-
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
89+
- (void)application:(UIApplication *)application
90+
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
91+
[RNCPushNotificationIOS
92+
didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
7893
}
79-
// Required for the notification event. You must call the completion handler after handling the remote notification.
80-
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
81-
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
82-
{
83-
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
94+
// Required for the notification event. You must call the completion handler
95+
// after handling the remote notification.
96+
- (void)application:(UIApplication *)application
97+
didReceiveRemoteNotification:(NSDictionary *)userInfo
98+
fetchCompletionHandler:
99+
(void (^)(UIBackgroundFetchResult))completionHandler {
100+
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo
101+
fetchCompletionHandler:completionHandler];
84102
}
85103
// Required for the registrationError event.
86-
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
87-
{
88-
[RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
104+
- (void)application:(UIApplication *)application
105+
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
106+
[RNCPushNotificationIOS
107+
didFailToRegisterForRemoteNotificationsWithError:error];
89108
}
90109
// Required for the localNotification event.
91-
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
92-
{
93-
[RNCPushNotificationIOS didReceiveLocalNotification:notification];
110+
- (void)application:(UIApplication *)application
111+
didReceiveLocalNotification:(UILocalNotification *)notification {
112+
[RNCPushNotificationIOS didReceiveLocalNotification:notification];
94113
}
95114
// IOS 10+ Required for local notification tapped event
96115
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
97-
didReceiveNotificationResponse:(UNNotificationResponse *)response
98-
withCompletionHandler:(void (^)(void))completionHandler
99-
{
116+
didReceiveNotificationResponse:(UNNotificationResponse *)response
117+
withCompletionHandler:(void (^)(void))completionHandler {
100118
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
101119
completionHandler();
102120
}
103121

104-
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
105-
{
122+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
106123
#if DEBUG
107-
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
124+
return
125+
[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"
126+
fallbackResource:nil];
108127
#else
109-
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
128+
return [[NSBundle mainBundle] URLForResource:@"main"
129+
withExtension:@"jsbundle"];
110130
#endif
111131
}
112132

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"devDependencies": {
4646
"@babel/core": "^7.0.0",
47-
"@react-native-community/eslint-config": "^1.0.0",
47+
"@react-native-community/eslint-config": "^2.0.0",
4848
"babel-core": "^7.0.0-bridge.0",
4949
"babel-jest": "24.1.0",
5050
"babel-plugin-module-resolver": "^3.1.3",
@@ -54,7 +54,7 @@
5454
"metro-react-native-babel-preset": "0.58.0",
5555
"react": "16.11.0",
5656
"react-native": "0.62.2",
57-
"typescript": "^3.8.3"
57+
"typescript": "^3.9.5"
5858
},
5959
"repository": {
6060
"type": "git",

0 commit comments

Comments
 (0)