mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
[ReactNative] Add deep linking api
This commit is contained in:
@@ -17,6 +17,5 @@
|
||||
|
||||
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
|
||||
+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification;
|
||||
+ (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#import "RCTEventDispatcher.h"
|
||||
|
||||
NSString *const RCTRemoteNotificationReceived = @"RemoteNotificationReceived";
|
||||
NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
||||
|
||||
@implementation RCTPushNotificationManager
|
||||
{
|
||||
@@ -35,10 +34,6 @@ NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
||||
selector:@selector(handleRemoteNotificationReceived:)
|
||||
name:RCTRemoteNotificationReceived
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleOpenURLNotification:)
|
||||
name:RCTOpenURLNotification
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -62,30 +57,12 @@ NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
||||
userInfo:notification];
|
||||
}
|
||||
|
||||
+ (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation
|
||||
{
|
||||
NSDictionary *payload = @{@"url": [url absoluteString]};
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
|
||||
object:self
|
||||
userInfo:payload];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)handleRemoteNotificationReceived:(NSNotification *)notification
|
||||
{
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived"
|
||||
body:[notification userInfo]];
|
||||
}
|
||||
|
||||
- (void)handleOpenURLNotification:(NSNotification *)notification
|
||||
{
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"openURL"
|
||||
body:[notification userInfo]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application icon badge number on the home screen
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user