-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introduce property on RCTPushNotificationManager to hold local notification that launched the app #42628
Conversation
This pull request was exported from Phabricator. Differential Revision: D52897071 |
63224b7
to
9a5c806
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
9a5c806
to
0deef62
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
…cation that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey when you warm start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that warm started the app. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. Differential Revision: D52897071
0deef62
to
bbe9d46
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
Base commit: 751eae9 |
bbe9d46
to
d424a71
Compare
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Differential Revision: D52897071
This pull request was exported from Phabricator. Differential Revision: D52897071 |
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Differential Revision: D52897071
d424a71
to
d4261ee
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Differential Revision: D52897071
d4261ee
to
e0c51e4
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Differential Revision: D52897071
e0c51e4
to
d609f1e
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Differential Revision: D52897071
d609f1e
to
c833e52
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
c833e52
to
5a3c397
Compare
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Reviewed By: ingridwang Differential Revision: D52897071
This pull request was exported from Phabricator. Differential Revision: D52897071 |
5a3c397
to
db38a0b
Compare
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Reviewed By: ingridwang Differential Revision: D52897071
This pull request was exported from Phabricator. Differential Revision: D52897071 |
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Reviewed By: ingridwang Differential Revision: D52897071
db38a0b
to
3a02bff
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
… that launched the app (facebook#42628) Summary: Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey # how to migrate: if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration. have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this. then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines: if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"] : [_bridge moduleForClass:[RCTPushNotificationManager class]]; if ([module isKindOfClass:[RCTPushNotificationManager class]]) { RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module; pushNotificationManager.initialLocalNotification = response.notification; } } # reasoning: when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address. apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module. another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate. in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer. Reviewed By: ingridwang Differential Revision: D52897071
3a02bff
to
6abc144
Compare
This pull request was exported from Phabricator. Differential Revision: D52897071 |
This pull request has been merged in c8ab44c. |
Summary:
Changelog: [Internal]
when you warm start an app from a push notification, the
UIApplicationLaunchOptionsLocalNotificationKey
inapplication:didFinishLaunchingWithOptions:
will contain the notification metadata that warm started the app. however,UIApplicationLaunchOptionsLocalNotificationKey
has been deprecated since iOS 10, which this PR aims to address.apple's supported API to do this is
userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:
which is onUNUserNotificationCenterDelegate
. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module.another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need
UNUserNotificationCenterDelegate
to be a top level object - usually the scope of the app delegate.Differential Revision: D52897071