Summary:
Hi React Native folks! Love your work!
To make contributing easier, this sets the indentation settings of all the Xcode projects to 2 spaces to match their contents.
Closes https://github.com/facebook/react-native/pull/15275
Differential Revision: D5526462
Pulled By: javache
fbshipit-source-id: cbf0a8a87a1dbe31fceed2f0fffc53839cc06e59
Summary:
<details>
Thanks for submitting a PR! Please read these instructions carefully:
- [ ] Explain the **motivation** for making this change.
- [ ] Provide a **test plan** demonstrating that the code is solid.
- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.
Please read the [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md) to learn more about contributing to React Native.
</details>
_What existing problem does the pull request solve?
In iOS when sending a silent push notification you need to configure the 'content-available' APS key to the value of 1 (When this key is present, the system wakes up your app in the background and delivers the notification to its app delegate, see [apple docs](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1)).
This PR exposes this property to the notification event handler so app code can handle silent push scenario specifically. Currently this property is not available.
I've updated the PushNotificationIOSExample in the RNTester.
1. Open RNTester in xcode
2. Enable the push notifications capability
3. run on device
4. Go to PushNotificationIOS
5. click on "send fake notification"
6. verify alert message contains 'content-available' with a value of 1.
Closes https://github.com/facebook/react-native/pull/14584
Differential Revision: D5279181
Pulled By: shergin
fbshipit-source-id: d2288e147d89ba267f54265d819aa0a9969095e7
Summary:
Thanks for submitting a PR! Please read these instructions carefully:
- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.
This change allows app code to access the 'category' property of incoming iOS remote push notifications. Currently the property is not made available.
Create a test application which:
- registers for remote notifications with APNs
- passes the returned token to your push notification service provider
- displays the contents of the notification, including the 'category'
Send a remote push notification including a value for the category property in the payload. Check that the category is displayed in the application.
I considered updating RNTester but I couldn't for the life of me figure out how to get it to compile on my machine, sorry ;-) I can confirm my change works when applied directly in the node_modules of an existing RN project.
I've signed the CLA. Hope this is enough info to go on, please let me know if not!
Closes https://github.com/facebook/react-native/pull/14322
Differential Revision: D5184941
Pulled By: javache
fbshipit-source-id: b69decedafac37a5212efcf32faf858aa67ed691
Summary:
Currently it's not possible to create a silent local notification (which is useful for badge updates) with PushNotificationIOS. This commit solves the problem - when **soundName** param is not specified in **PushNotificationIOS.scheduleLocalNotification** method, a silent notification will be created.
Local notification without sound:
```
let fireDate = new Date();
fireDate = fireDate.setSeconds(fireDate.getSeconds() + 15); //fire in 15 seconds
PushNotificationIOS.scheduleLocalNotification({
fireDate: fireDate,
alertBody: "I'm silent!"
});
```
Local notification with sound:
```
let fireDate = new Date();
fireDate = fireDate.setSeconds(fireDate.getSeconds() + 15); //fire in 15 seconds
PushNotificationIOS.scheduleLocalNotification({
fireDate: fireDate,
alertBody: "I'm with sound!",
soundName: "Any sound"
});
```
Closes https://github.com/facebook/react-native/pull/13734
Differential Revision: D5144848
Pulled By: shergin
fbshipit-source-id: dc990b2673305a01cfd868fcdedcf27c461d0a34
Summary:
I don't think editing the search path is necessary anymore for notifications since [0.40](https://github.com/facebook/react-native/releases/tag/v0.40.0).
I removed the part that says to edit the search paths, and changed `#import "RCTPushNotificationManager.h"` to `#import <React/RCTPushNotificationManager.h>` in the documentation
Thanks for submitting a PR! Please read these instructions carefully:
- [ ] Explain the **motivation** for making this change.
- [ ] Provide a **test plan** demonstrating that the code is solid.
- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.
What existing problem does the pull request solve?
A good test plan has the exact commands you ran and their output, provides screenshots or videos if the pull request changes UI or updates the website. See [What is a Test Plan?][1] to learn more.
If you have added code that should be tested, add tests.
Sign the [CLA][2], if you haven't already.
Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.
Make sure all **tests pass** on both [Travis][3] and [Circle CI][4]. PRs that break tests are unlikely to be merged.
For more info, see the ["Pull Requests"][5] section of our "Contributing" guidelines.
[1]: https://medium.com/martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9
[2]: https://code.facebook.com/cla
[3]: https://travis-ci.org/facebook/react-native
[4]: http://circleci.com/gh/facebook/react-native
[5]: https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests
Closes https://github.com/facebook/react-native/pull/13700
Differential Revision: D4969728
Pulled By: javache
fbshipit-source-id: d72aee1c5b8578cea27d6b7d45ee7a7f269433fc
Summary:
Resolves#13012
RCTPushNotificationManager uses startObserving to register for RCTRegisterUserNotificationSettings. According to the docs, the startObserving method won't be called until somebody subscribes to NotificationManagerIOS.
This means there is a scenario when the developer can call requestPermissions without subscribing to notifications first, but since RCTPushNotificationManager relies on NSNotificationCenter subscribtion, the result will never be returned.
When requesting permissions the promise will resolve:
`PushNotificationIOS.requestPermissions().then(console.log);` without the need for calling `PushNotificationIOS.addEventListener()` first.
Closes https://github.com/facebook/react-native/pull/13263
Differential Revision: D4851767
Pulled By: javache
fbshipit-source-id: 2be8621e072ae1086014594bc986ca5590b5eb61
Summary:
…th RCTSharedApplication()
Thanks for submitting a PR! Please read these instructions carefully:
- [ ] Explain the **motivation** for making this change.
Using React Native latest version with Cocoapods 1.2.0 causes the following error inside iOS app extensions
> /react-native/React/Modules/RCTAccessibilityManager.m:67:70: ‘sharedApplication’ is unavailable: not available on iOS (App Extension) — Use view controller based solutions where appropriate instead.
Moving the use of [UIApplication sharedApplication] to RCTSharedApplication() which is safe on app extension
- [ ] Provide a **test plan** demonstrating that the code is solid.
I am not sure how to test such that all the features which touch the modified code are tested.
- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.
What existing problem does the pull request solve?
Using React Native latest v
Closes https://github.com/facebook/react-native/pull/13227
Differential Revision: D4816338
Pulled By: javache
fbshipit-source-id: e3e3c77882990ad1817b0b633521cff52571ecd0
Summary:
This is enforced for all of our internal iOS code and a common cause of import failures.
cc janicduplessis
Closes https://github.com/facebook/react-native/pull/13124
Differential Revision: D4765016
fbshipit-source-id: 7c8248c98bca0fa6bad24d5a52b666243375e0db
Summary:
Implementing removeAllDeliveredNotifications and removeDeliveredNotifications for remove notifications from notification center, and getDeliveredNotifications
Thanks for submitting a PR! Please read these instructions carefully:
- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.
Currently, calling PushNotificationIOS.cancelAllLocalNotifications not remove the notification from the Notification Center
In iOS 10, a new UNUserNotification class was introduced, this class has a method which get and remove the notifications from notification center
This PR try to solve that.
In my case, i'm working with an messaging app, every message is a new notification, when the user tap a notification, the app is opened and the rest of notifications should be gon
Closes https://github.com/facebook/react-native/pull/13036
Differential Revision: D4761828
Pulled By: javache
fbshipit-source-id: 216e44a64f1bf88b5ae3045d1fa6eca8a1278a71
Summary:
Various fixes of xcode projects and cleaning up some warnings
Closes https://github.com/facebook/react-native/pull/13109
Differential Revision: D4762652
Pulled By: lacker
fbshipit-source-id: b452976a58962439de4adecc8e703264af40cb38
Summary:
Xcode really sucks, per some discussion on e1577df1fd and https://developer.apple.com/library/content/technotes/tn2215/_index.html, if you use the headers phase, and mark headers in your static library as public, they will actually end up in the final package that's built and you can't submit to the app store! This changes our xcode setup to use a copy files phase instead.
I've also changed the header include path to be $(BUILT_PRODUCTS_DIR)/include, which is added to the include path by Xcode by default, so 3rd party libraries should not be impacted by these changes anymore.
Reviewed By: mkonicek
Differential Revision: D4291607
fbshipit-source-id: 969b9ebcbeb8161f85427f8c429e198d9d0fae30
Summary:
This PR seeks to improve the documentation of PushNotificationIOS.
The method didReceiveRemoteNotification without a fetch completion handler is deprecated by Apple and they [discourage using it](https://developer.apple.com/reference/uikit/uiapplicationdelegate/1623117-application) in favor of the [version with the handler](https://developer.apple.com/reference/uikit/uiapplicationdelegate/1623013-application).
Reasons for this change:
1. Our docs say that this method is required for remote notifications, but it's not. (It's one of possibilities with a recommendation not to use it.)
2. The method is deprecated by Apple and people shouldn't use it.
3. If you use the deprecated method, in 99% of the cases it will behave in a different way from what you'd expect. In particular, you won't get remote notifications when your app is in the background.
As there's no benefit (as far as I know) of using the method, I don't think we should even mention it to the users.
This is a re-opened PR that was mis
Closes https://github.com/facebook/react-native/pull/11109
Differential Revision: D4232800
Pulled By: javache
fbshipit-source-id: d3b509db41a549aa7fbc41753c648085df43d8ee
Summary:
To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes.
Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build".
Reviewed By: mmmulani
Differential Revision: D4213120
fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
Summary: Correct header import paths, update podspec so we point at the copy in ReactCommon (and can eventually remove the copy under React)
Reviewed By: astreet
Differential Revision: D4204501
fbshipit-source-id: e979a010092f025b2cdc289e1e5f22fc7b65a8d1
Summary:
If we are using the same handler for different events, e.g. both `notification` and `localNotification` use `_onNotification()` handler, the former listener stored in `_notifHandlers` would be overridden by the latter so it's impossible to remove the `notification` listener when we call `removeEventListener`.
This PR stores the listeners by using `pushNotificationEventName` (notification, localNotification, register or registrationError) as the key.
Use the same handler for `notification` and `localNotification`, both listeners will be removed when calling `removeEventListener`.
Closes https://github.com/facebook/react-native/pull/10776
Differential Revision: D4168722
Pulled By: hramos
fbshipit-source-id: d68581428d2acde314f7b5333feafe1ec7807159
Summary:
- Consolidate common code in iOS and tvOS test scripts
- Start the packager before starting tests, to improve reliability
- Increase timeout value in RCTTestRunner.m
Closes https://github.com/facebook/react-native/pull/10378
Differential Revision: D4028364
Pulled By: bestander
fbshipit-source-id: 24c2124a1c62643a02f0668b60a67b971e08d1a3
Summary:
This just cleans up the work done in #7219 by adamterlson based on grabbou's feedback
Closes https://github.com/facebook/react-native/pull/10337
Differential Revision: D4001540
Pulled By: javache
fbshipit-source-id: c73b5fef912fa71d1d988dae41094c9c46dc610b
Summary:
This is an updated version of #2336 and #7694.
---
This adds a `registrationError` event that is emitted by `PushNotificationIOS` whenever an application receives a registration error from APNS (APNS service failure, running on simulator, etc). This event fires to the exclusion of the `register` event (and vice versa).
**How to use**
Add the following to your `AppDelegate.m`:
```obj-c
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}
```
And register an event handler for the event:
```js
PushNotificationIOS.addEventListener('registrationError', function({ message, code }) {
// Complete your registration process in error.
});
```
**Test plan**
Added support for this event (and `register`) to UIExplorer as a proof of concept. Navigating to the push notifications example on a simulator is an easy way to reproduce this e
Closes https://github.com/facebook/react-native/pull/9650
Differential Revision: D3822142
Pulled By: javache
fbshipit-source-id: a15ed8941b74dc3eed2c44c658deccbcaf39ce3d
Summary:
The docs heavily implied that this method returned a notification object or null directly, like popInitialNotification used to do. In fact, it returns a promise. This change clarifies this.
Note that:
- This is purely a comment change, so no testing required.
- I've adhered to the 80 character line limit, and can't think of any other style rules you might have that could apply here.
Closes https://github.com/facebook/react-native/pull/9052
Differential Revision: D3662807
Pulled By: javache
fbshipit-source-id: 7a2573e03d7704b2d62a3499d350506ae73e8d77
Summary:
It seems it's a common problem people trying to register for push notifications in their simulator, and not understanding why the "register" event never works.
I've wasted a few hours myself on this issue.
This commit simply logs any failures with push registration, preventing confusion.
Closes https://github.com/facebook/react-native/pull/8046
Differential Revision: D3454922
Pulled By: javache
fbshipit-source-id: a96896d97d97cfe1bd319e6490750838dfaad3cd
Summary:
Currently if an RN app is started in response to a remote notification, that notification's data is available on startup via `PushNotificationIOS.popInitialNotification()`. However, if the app is started in response to a "local" notification, that information is never passed in. This PR modifies the `popInitialNotification` behavior so it will return the notification used to launch the app, no matter if it was local or remote.
I've tested this change in my app and ensured that when the app is woken up with a `localNotification` it's passed in to `PushNotificationIOS.popInitialNotification`. I've also tested that the `localNotification` event continues working as before.
Closes https://github.com/facebook/react-native/pull/7765
Differential Revision: D3417267
Pulled By: nicklockwood
fbshipit-source-id: 0b5b432e9a75dda7d3c50289a3bf0f1c1ffcf061
Summary:
The documentation currently list a few but not all of the steps required. This changes completes that list of required project changes.
This addresses #5612
Closes https://github.com/facebook/react-native/pull/7985
Differential Revision: D3414576
Pulled By: nicklockwood
fbshipit-source-id: 2c7ea6598ee4cd8b6945d9bb229bed5b592a68f6
Summary:
_(This is a remake of #6907, which I botched pretty good with a rebase.)_
This returns an `Array` of Local Notifications that have been scheduled to be delivered.
Available attributes on return Notification object (if set in the local notification itself):
`alertAction`
`alertBody`
`applicationIconBadgeNumber`
`category`
`fireDate`
`soundName`
`userInfo`
More could be added to this but I just matched what was available in the `Object` passed to `presentLocalNotification` and `scheduleLocalNotification`.
**Motivation**
I needed to determine the number and other details about local notifications that were already scheduled. There is an API for this in iOS but one hadn't been built yet for React Native.
I created the Obj-C method and updated the documentation in `PushNotificationIOS.js` as well.
**Usage:**
```js
PushNotificationIOS.getScheduledLocalNotifications( (notifications) => {
console.log(notifications);
});
```
**Sample Output:**
```js
[
Object {
aler
Closes https://github.com/facebook/react-native/pull/7937
Differential Revision: D3392476
Pulled By: javache
fbshipit-source-id: d83f419bfcfbdaf9b955724dcf5cfe26834895fb
Summary:
**Motivation**
Today it's hard to build a good flow around requesting permissions if we don't know when the user rejects the push notification permission.
With this PR I wrap `PushNotificationIOS#requestPermission` in a promise. The promise will return with the updated permissions when the user accepts, rejects or has previously rejected the permission.
An example flow of how an app should handle push notifications with the change proposed:
1) Show user an explanation of push notification permissions with a button to enable,
2) User presses the enable push notifications button,
3) If the user accepts -> take them into the app,
4) if the user rejects -> explain how to enable permission in the settings app.
5) My app will now store some state about how it has asked permissions for push notifications so that the next time the user is taken through this flow they will go straight to step 4.
Without this change we could listen to the `register` event that PushNotificationIOS fires on the success sc
Closes https://github.com/facebook/react-native/pull/7900
Differential Revision: D3387424
Pulled By: nicklockwood
fbshipit-source-id: e27df41e83216e4e2a14d1e42c6b26e72236f48c
Summary: Updated networking and geolocation to use the new events system.
Reviewed By: bestander
Differential Revision: D3346129
fbshipit-source-id: 957716e54d7af8c4a6783f684098e92e92f19654
Summary: Updated networking and geolocation to use the new events system.
Reviewed By: javache
Differential Revision: D3339945
fbshipit-source-id: 01d307cf8a0aea3a404c87c6205132c42290abb1
Summary: Updated networking and geolocation to use the new events system.
Reviewed By: javache
Differential Revision: D3339945
fbshipit-source-id: f1332fb2aab8560e4783739e223c1f31d583cfcf
Summary:
Modules which call JS methods directly, or use `sendDeviceEventWithName:`, can trigger effects in JS without ever being referenced from the JS code. This breaks some assumptions in my earlier diff about when modules can be lazily loaded.
Pending a better solution, I've put explicit `init` methods in these modules to ensure they are eagerly initialized (the downside to this is that they'll still be initialized even if they are never used).
Reviewed By: javache
Differential Revision: D3258232
fb-gh-sync-id: f925bc2e5339c1fbfcc244d4613062c5ab848fc2
fbshipit-source-id: f925bc2e5339c1fbfcc244d4613062c5ab848fc2
Summary:
Added support for setting an optional badge icon number and alert action when using local notifications.
Closes https://github.com/facebook/react-native/pull/2931
Differential Revision: D3212448
Pulled By: mkonicek
fb-gh-sync-id: 063efcdd259b2a43f39812f57a71e8489ab33653
fbshipit-source-id: 063efcdd259b2a43f39812f57a71e8489ab33653
Summary:Follow-up to https://github.com/facebook/react-native/pull/5084
This…
- changes all requires within RN to `require('fbjs/lib/…')`
- updates `.flowconfig`
- updates `packager/blacklist.js`
- adapts tests
- removes things from `Libraries/vendor/{core,emitter}` that are also in fbjs
- removes knowledge of `fbjs` from the packager
Closes https://github.com/facebook/react-native/pull/5084
Reviewed By: bestander
Differential Revision: D2926835
fb-gh-sync-id: 2095e22b2f38e032599d1f2601722b3560e8b6e9
shipit-source-id: 2095e22b2f38e032599d1f2601722b3560e8b6e9
Summary:Hello!
As described in #3288, the `PushNotificationsIOS` `register` callback fires twice. See that issue for discussion.
There wasn't any feedback on a proposed PR, so this is the first effort. This change does make the register callback act as expected on my device. I can make any changes necessary.
Thanks!
Closes https://github.com/facebook/react-native/pull/6111
Differential Revision: D2970806
Pulled By: nicklockwood
fb-gh-sync-id: a8d0b53210f85cc24b4befdb0e90af46512fa4fb
shipit-source-id: a8d0b53210f85cc24b4befdb0e90af46512fa4fb
Summary:In order to use iOS notification actions with local notifications, we need to be able to specify a category string. This PR adds a category property to the `details` object used to create a local notification.
I also added support for the `alertAction` property, which is used to control the "slide to {alertAction}" text beneath the notification.
Finally, I added the doc for `userInfo` to `presentLocalNotification` (previously was only documented for `scheduleLocalNotification`.
**Test plan (required)**
I implemented the example from the [react-native-ios-notification-actions README](https://github.com/holmesal/react-native-ios-notification-actions), and created a couple of actions and grouped them under a category with identifier `something_happened`.
Prior to the changes in this PR, the shown local notification would not contain any actions.
With the changes in this PR, the shown local notification contains the specified actions.
Like so:
![demo](https://camo.githubusercontent.com/c4a86
Closes https://github.com/facebook/react-native/pull/5994
Differential Revision: D2953919
Pulled By: nicklockwood
fb-gh-sync-id: a05a9ea9ae8c150ff0714e106410e094c2747eca
shipit-source-id: a05a9ea9ae8c150ff0714e106410e094c2747eca
Summary:
This commit adds the delegate hooks so that local notifications get
passed onto the JS and adds a new event listener type for local
notifications.
Also add functions to clear local notifications
Closes https://github.com/facebook/react-native/pull/2084
Reviewed By: svcscm
Differential Revision: D2908096
Pulled By: nicklockwood
fb-gh-sync-id: 759d299ea35abea177e72934076297d666d3ea20
shipit-source-id: 759d299ea35abea177e72934076297d666d3ea20