fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 990 forks source link

problem with putting GoogleServices-Info.plist #141

Open sonrebmax opened 7 years ago

sonrebmax commented 7 years ago

*\ Terminating app due to uncaught exception 'com.firebase.core', reason: '[FIRApp configure] could not find a valid GoogleServices-Info.plist in your project. Please download one from https://console.firebase.google.com/.'

I added manually to: www/ /

added scripts/after_prepare.js and hook in plugin.xml

no problem solved yet...

please help

sonrebmax commented 7 years ago

I have temporary solution for this:

cp GoogleService-Info.plist platforms/ios/build/device/APPNAME.app/ && ios-deploy --justlaunch --no-wifi -d -b platforms/ios/build/device/APPNAME.app

GitFr33 commented 7 years ago

I am having the same problem.

charles-inman commented 7 years ago

Same issue this is in phonegap for me FAILURE: Build failed with an exception.

but the file is directly in the root directory i evenattempted even /project/src/release creating that file structure

BananZG commented 7 years ago

instead of putting them under the project's root directory, what i do is to put them under individual platform's directory. For example: I put the 'AndroidManifest.xml' file under _yourproject/platforms/android and for ios, put 'GoogleService-Info.plist' under _yourproject/platforms/ios

dannywillems commented 7 years ago

@divinity-comp @sonrebmax @GitFr33: The solution is what @BananZGan said:

I hope we can have something like a hook which copies the files from the root Cordova project (so where www and config.xml are) automatically.

fechanique commented 7 years ago

I have some solutions for the hook, but I need to test them first

On 14 Oct 2016 11:49, "Danny Willems" notifications@github.com wrote:

@divinity-comp https://github.com/divinity-comp @sonrebmax https://github.com/sonrebmax @GitFr33 https://github.com/GitFr33: The solution is what @BananZGan https://github.com/BananZGan said:

  • For Android: put google-services.json in the directory platforms/android.
  • For iOS: add the platform ios, and add Google-Services.plist in the root folder of the XCode project.

I hope we can have something like a hook which copies the files from the root Cordova project (so where www and config.xml are) automatically.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fechanique/cordova-plugin-fcm/issues/141#issuecomment-253756816, or mute the thread https://github.com/notifications/unsubscribe-auth/ANXY-1Ip-QRXNKgh9a_4vVAZsh0NTCMcks5qz1AwgaJpZM4KU6nd .

dannywillems commented 7 years ago

phonegap-plugin-push implements a simple hook. It could inspire. @fechanique

fechanique commented 7 years ago

also I have some pull request with the solution, I only need some time :D

On 14 Oct 2016 11:51, "Danny Willems" notifications@github.com wrote:

phonegap-plugin-push implements a simple hook. It could inspire.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fechanique/cordova-plugin-fcm/issues/141#issuecomment-253757286, or mute the thread https://github.com/notifications/unsubscribe-auth/ANXY-91T401ro2ezM1TWWo-9Ugu2OmEtks5qz1C4gaJpZM4KU6nd .

GitFr33 commented 7 years ago

I'm still getting this error after copying my GoogleService-Info.plist into platforms/ios (and several other directories for good measure).

I'm using cordova version 6.3.1, Xcode 7.3.1, iOS 9.3

Any suggestions?

benlooi commented 7 years ago

I had this a few times. What I did was to add the GoogleService-Info.plist into the Resources folder in XCode. For some reason a blank GoogleService-Info.plist is created, which has to be replaced. 1) right-click the GoogleService-Info.plist under the Resources folder if it exists. If it shows up blank, delete it. 2) Next, right-click on Resources folder, add files, then find your downloaded plist and add it in. You can also try dragging it from your Finder window to the Resources folder in XCode.

GitFr33 commented 7 years ago

Thanks benlooi! After adding GoogleService-Info.plist to the resources folder as you suggested it seems to be working. I am not getting any notifications unless the app is open, but that is a different issue.

julitroalves commented 7 years ago

Thanks @benlooi! After adding G..plist file to Resources my app finally works.

arnoldmukisa commented 7 years ago

Adding the GoogleService-Info.plist file to resources manually in Xcode worked.

MariusIlie14 commented 7 years ago

Yes but this is a temporary solution as the issue persists in cordova 7.0.1 with xcode 8.3.2 as well . Has there any other fix been done ?

DropkickSteve commented 7 years ago

I think this is a bug of Xcode. When i add platform ios, the GoogleService-Info.plist is placed correctly in /platforms/ios/myApp/Resources/. However it has to be manually added in the Resources folder of Xcodes project navigator.

ricardojlrufino commented 6 years ago

I think that in XCode Resources is a virtual folder... or is a Bug ..

image

DropkickSteve commented 6 years ago

@ricardojlrufino I agree. If I manually put the GoogleService-Info.plist file in the Resources folder in Xcode, it then appears in the filesystem in Finder. However when my script puts the file in the Resources folder of the filesystem, it does not show in the Resources folder of Xcode.

manfield commented 6 years ago

Hi Everybody, so there won't be any programmatic solution to that?

bunday commented 6 years ago

im still experiencing this error, about to remove and add ios platform and manually copy the file now. i hope it works

manfield commented 6 years ago

I found a programmatic solution, with after_prepare hook script

Adding these instructions:

  copyFile("../GoogleService-Info.plist", "../platforms/ios/GoogleService-Info.plist");

then

      var pbxGroupKey = proj.findPBXGroupKey({
        name: "Resources"
      });
      proj.removeResourceFile('GoogleService-Info.plist', {}, pbxGroupKey);
      proj.addResourceFile('GoogleService-Info.plist', {}, pbxGroupKey);

where proj is:

  var projectPath = "platforms/ios/MyProj.xcodeproj/project.pbxproj";
  var proj = new xcode.project(projectPath);

You need this lib:

var xcode = require('xcode');

atjason commented 6 years ago

Just FYI, I solved this issue by add a copy step. 2203101

The key point is, the 'GoogleService-Info.plist' should be copied to the root path of .app. 2205161

manfield commented 6 years ago

Ok, but since project is generated for each cordova build I think you'd get this setting lost after the next build. Actually not every build, but every platform prepare.

ank-it commented 6 years ago

@atjason Thank you for pointing out the right solution. Works like charm. It should be in the official documentation of Firebase if this is not a bug.

atjason commented 6 years ago

@ank-it Welcome. I also wonder why Firebase official document miss such information.

tumocpc commented 6 years ago

I found the reason why the googleservice-info.plist file is corrupted. This is plugin problem and I fixed it. please add this plugin in your ionic project, and then it will fix your problems. https://github.com/tumocpc/cordova-plugin-fmc.git It does not require work that you should add googleservice-info.plist manuallly.

mkwsra commented 6 years ago

In my case, I didn't download GoogleService-info.plist from firebase, thus, I was using always an empty version of it! Plus, drag and drop this file into Resources folder didn't help me, I had to right click then choose Add Files to FooBar.

Thanks a lot for helping me out! I have been struggling with this issue!

epetre commented 6 years ago

@manfield has the best solution here. It's just missing some steps.

var projectPath = "platforms/ios/{YOUR_PROJECT_NAME}.xcodeproj/project.pbxproj";
var proj = new xcode.project(projectPath);
proj.parseSync();
var pbxGroupKey = proj.findPBXGroupKey({ name: "Resources" });
proj.removeResourceFile('GoogleService-Info.plist', {}, pbxGroupKey);
proj.addResourceFile('GoogleService-Info.plist', {}, pbxGroupKey);
fs.writeFileSync(projectPath, proj.writeSync());

Just the parse and saving of the file.

I also copy my file from root, this way you can remove the platform and it still works:

fs.copyFile("GoogleService-Info.plist", "platforms/ios/{YOUR_PROJECT_NAME}/Resources/GoogleService-Info.plist", (err) => {
  if (err) throw err;
  console.log('GoogleService-Info.plist was copied to platforms/ios/GoogleService-Info.plist');
});

thx @manfield