Failed to apply patch with multiple file changes with yarn
See original GitHub issueWith yarn v1.10.1 and postinstall-postinstall
Error Message
v5:
This error was caused because Git cannot apply the following patch file:
patches/react-native-firebase+5.0.0.patch
This is usually caused by inconsistent whitespace in the patch file.
v6:
This error was caused because patch-package cannot apply the following patch file:
patches/react-native-firebase+5.0.0.patch
Diff
patch-package
--- a/node_modules/react-native-firebase/dist/index.d.ts
+++ b/node_modules/react-native-firebase/dist/index.d.ts
@@ -1179,6 +1179,8 @@ declare module 'react-native-firebase' {
*/
getToken(): Promise<string>;
+ getAPNSToken(): Promise<string>;
+
deleteToken(authorizedEntity?: string, scope?: string): Promise<void>;
/**
--- a/node_modules/react-native-firebase/dist/modules/messaging/index.js
+++ b/node_modules/react-native-firebase/dist/modules/messaging/index.js
@@ -46,6 +46,10 @@ export default class Messaging extends ModuleBase {
return getNativeModule(this).getToken();
}
+ getAPNSToken() {
+ return getNativeModule(this).getAPNSToken();
+ }
+
deleteToken(authorizedEntity, scope) {
return this.app.iid().deleteToken(authorizedEntity, scope);
}
--- a/node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m
+++ b/node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m
@@ -126,6 +126,20 @@ RCT_EXPORT_METHOD(getToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseR
}
}
+RCT_EXPORT_METHOD(getAPNSToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
+ NSData *apnsToken = [FIRMessaging messaging].APNSToken;
+ if (apnsToken) {
+ const char *data = [apnsToken bytes];
+ NSMutableString *token = [NSMutableString string];
+ for (NSInteger i = 0; i < apnsToken.length; i++) {
+ [token appendFormat:@"%02.2hhX", data[i]];
+ }
+ resolve([token copy]);
+ } else {
+ reject(@"messaging/fcm-token-error", @"Failed to retrieve APNS token.", nil);
+ }
+}
+
RCT_EXPORT_METHOD(requestPermission:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
if (RCTRunningInAppExtension()) {
reject(@"messaging/request-permission-unavailable", @"requestPermission is not supported in App Extensions", nil);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Getting errors when patching a npm package - Stack Overflow
The problem here is that you're using two different tools to patch the npm package, and using a different one locally than in...
Read more >Patch-package NPM
Specify the name for the directory in which to put the patch files. ... This happens even after failing to apply patches because...
Read more >Create Patches - GitLab Docs
To apply patch files, store .patch files that contain the changes in a specific ... Use the git diff command to create a...
Read more >patch(1) - Linux manual page - man7.org
patch - apply a diff file to an original ... If that fails, and the maximum fuzz factor is set to 2 or...
Read more >patch-package | Fix broken node modules instantly - YouTube
patch -package is a tool that has saved me a couple of times when I found a bug in an npm package and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m closing this to tidy up. Have completely refactored the patch application code and tested it in different envs. Seems to work well. If you still have trouble feel free to open another issue.
6.0 will be leaving beta very very shortly!
My bad, I was running with patch-package@5. I tried with v6 and it works. The initial patch was huge, package’s node_modules was included in the patch. I ended to this: