Unable to create platform iOS using phongap push plugin

Hi everyone, Can you pls help me out to figure out this problem, I am new to IONIC , creating push notification application.
The application platform added successfully in windows for android, but in mac I failed with this message.

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add ios --save (exit code 1):

    Using cordova-fetch for cordova-ios@^4.4.0
    Adding ios project...
    Creating Cordova project for the iOS platform:
    	Path: platforms/ios
    	Package: com.onebcg.pushtest
    	Name: MyApp
    iOS project created with cordova-ios@4.4.0
    Installing "phonegap-plugin-push" for ios
    Failed to install 'phonegap-plugin-push': undefined
    Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
    
    Usage:
    
        $ pod COMMAND
    
          CocoaPods, the Cocoa library package manager.
    
    Commands:
    
        + cache      Manipulate the CocoaPods cache
        + env        Display pod environment
        + init       Generate a Podfile for the current directory
        + install    Install project dependencies according to versions from a
                     Podfile.lock
        + ipc        Inter-process communication
        + lib        Develop pods
        + list       List pods
        + outdated   Show outdated project dependencies
        + repo       Manage spec-repositories
        + setup      Setup the CocoaPods environment
        + spec       Manage pod specs
        + update     Update outdated project dependencies and create new Podfile.lock
    
    Options:
    
        --silent     Show nothing
        --version    Show the version of the tool
        --verbose    Show more debugging information
        --no-ansi    Show output without ANSI codes
        --help       Show help banner of specified command
    	from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:47:in `run'
    	from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top (required)>'
    	from /usr/local/bin/pod:23:in `load'
    	from /usr/local/bin/pod:23:in `<main>'

oneadmins-iMac:pustTest onebcg$ sudo cordova platform add ios
Password:
Sorry, try again.
Password:
Using cordova-fetch for cordova-ios@^4.4.0
Error: Platform ios already added.
oneadmins-iMac:pustTest onebcg$
[Restored May 19, 2017, 4:22:09 PM]
Last login: Fri May 19 16:21:57 on console
oneadmins-iMac:pustTest onebcg$
[Restored May 19, 2017, 4:32:11 PM]
Last login: Fri May 19 16:31:46 on console
oneadmins-iMac:pustTest onebcg$ sudo ionic build ios
Password:
The build command has been renamed. To find out more, run:

ionic cordova build --help

oneadmins-iMac:pustTest onebcg$ sudo ionci cordova build ios
sudo: ionci: command not found
oneadmins-iMac:pustTest onebcg$ sudo ionic cordova build ios

cordova platform add --save ios
:heavy_multiplication_x: Running command - failed!
[ERROR] An error occurred while running cordova platform add --save ios (exit code 1):

    Using cordova-fetch for cordova-ios@^4.4.0
    Adding ios project...
    Creating Cordova project for the iOS platform:
    	Path: platforms/ios
    	Package: com.onebcg.pushtest
    	Name: MyApp
    iOS project created with cordova-ios@4.4.0
    Installing "phonegap-plugin-push" for ios
    Failed to install 'phonegap-plugin-push': undefined
    Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
    
    Usage:
    
        $ pod COMMAND
    
          CocoaPods, the Cocoa library package manager.
    
    Commands:
    
        + cache      Manipulate the CocoaPods cache
        + env        Display pod environment
        + init       Generate a Podfile for the current directory
        + install    Install project dependencies according to versions from a
                     Podfile.lock
        + ipc        Inter-process communication
        + lib        Develop pods
        + list       List pods
        + outdated   Show outdated project dependencies
        + repo       Manage spec-repositories
        + setup      Setup the CocoaPods environment
        + spec       Manage pod specs
        + update     Update outdated project dependencies and create new Podfile.lock
    
    Options:
    
        --silent     Show nothing
        --version    Show the version of the tool
        --verbose    Show more debugging information
        --no-ansi    Show output without ANSI codes
        --help       Show help banner of specified command
    	from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:47:in `run'
    	from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top (required)>'
    	from /usr/local/bin/pod:23:in `load'
    	from /usr/local/bin/pod:23:in `<main>'

seems no body here to reply

hey,

Im having the same issue… Im tired of this…

Finally I resolved this issue by doing following things , as it was mismatch versions issue

sudo npm uninstall -g cordova
sudo npm uninstall -g ionic

npm install -g ionic@2.2.3
npm install -g cordova@7.0.1

delete npm module and platform folder

then, run npm install, or further your plugins.
create platform
build

Hope this will help you

I just solved this issue.
You need to install pod files for push notification in OSX.
you need to use this command “pod install” at path “project/platforms/ios”.
make sure you have the file named Podfile or pods.json

1 Like

This doesn’t really make sense. If you have Ionic CLI v3 or v2.2.3 installed makes no difference for plugin installation (besides the command to use). Both just pass it off to Cordova in the background to execute the command.

In my case it worked, because the cause of issue can be different as in my case it was some plugins version issue. As it was fixed when I reinstall the ionic to lower version which matched with the cordova plugin which I installed in previous case

Sorry, I am happy for you that it worked, but Ionic CLI (v2 and v3) has no connection to a specific cordova version, plugin version or anything - that is all completely independent of Ionic CLI.

yep i confirm. I had to first remove ios, update pod and then install… tired of this

Hi,
I have the same issue, someone solved it?
I got this error: "Plugin doesn’t support this project’s cordova-ios version. cordova-ios: 4.3.1, failed version requirement: >=4.4.0"
and can’t update the cordova-ios version :frowning:

I had the same error and i changed plugin just because i couldn’t update cordova-ios version.

use cordova-plugin-fcm plugin.
Here is tutorial

http://simonwillshire.com/blog/Ionic-2-FCM-Notifications/

It’s working perfectly.

Thanks, I’ll try it :slight_smile:

Hi,
when I tried to add ‘cordova-plugin-fcm’ plugin I got “Error: Invalid data, chunk must be a string or buffer, not object”, do you know what is mean?
Thanks!

Make sure you download google-services.json file from firebase console after creating
API key at platform/android and root folder of your project.

If you have that file placed, make sure that file contains valid API key or else try creating new Key and replace new google-services.json file.

Thanks.

@ravi_sojitra Thanks it seems this will work. But while running it in simulator I faced this error

017-06-01 17:41:29.625 MyFCMApp[4325] [Firebase/Core][I-COR000009] The GOOGLE_APP_ID either in the plist file ‘GoogleService-Info.plist’ or the one set in the customized options is invalid. If you are using the plist file, use the iOS version of bundle identifier to download the file, and do not manually edit the GOOGLE_APP_ID. You may change your app’s bundle identifier to ‘(null)’. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.
2017-06-01 17:41:29.632 MyFCMApp[4325:59891] *** Terminating app due to uncaught exception ‘com.firebase.core’, reason: ‘Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.’
*** First throw call stack:
(
0 CoreFoundation 0x00000001039f9d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010343221e objc_exception_throw + 48
2 CoreFoundation 0x0000000103a632b5 +[NSException raise:format:] + 197
3 MyFCMApp 0x00000001028ef6ed +[FIRApp addAppToAppDictionary:] + 371
4 MyFCMApp 0x00000001028eec98 +[FIRApp configureDefaultAppWithOptions:sendingNotifications:] + 285
5 MyFCMApp 0x00000001028ee9cc +[FIRApp configure] + 302
6 MyFCMApp 0x00000001028857ef -[AppDelegate(MCPlugin) application:customDidFinishLaunchingWithOptions:] + 767
7 UIKit 0x000000010572c3c2 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 290
8 UIKit 0x000000010572dd47 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4236
9 UIKit 0x00000001057340ed -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731
10 UIKit 0x000000010573126d -[UIApplication workspaceDidEndTransaction:] + 188
11 FrontBoardServices 0x00000001091776cb FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24
12 FrontBoardServices 0x0000000109177544 -[FBSSerialQueue _performNext] + 189
13 FrontBoardServices 0x00000001091778cd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
14 CoreFoundation 0x000000010399e761 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
15 CoreFoundation 0x000000010398398c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x0000000103982e76 __CFRunLoopRun + 918
17 CoreFoundation 0x0000000103982884 CFRunLoopRunSpecific + 420
18 UIKit 0x000000010572faea -[UIApplication _run] + 434
19 UIKit 0x0000000105735c68 UIApplicationMain + 159
20 MyFCMApp 0x0000000102883261 main + 65
21 libdyld.dylib 0x00000001049a768d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

I have compared the bundle id which is right.
Can you please help me out to fix this?
Thanks

Remove the GoogleService-Info.plist file and download new file from firebase console for ios.
Replace that new file . :slight_smile:

@ravi_sojitra I already done this, but didn’t work.
I think I should create new bundle id and then new project in firebase console and try again.
Also I moved with APN auth .p8 certificate, so that now I don’t care about ssl certificates etc.

Any suggesting pls

Did you upload .p12 development and ditribution certificate in firebase while linking ios app?
Because without that you’re not gonna get notification.

I faced a server error while uploading .p12 and prvisonal files. Put the bug to FCM support. They asked me to use auth p8 based certification as its more easy way of authentication. I did, but still I am facing same issue on running in simulator

@ravi_sojitra issue resolved :smiley:

Thanks for great idea ( FCM) instead of IONIC cloud which is not much feasible for iOS push notification process.

Mine issue fixed when I copied manually .plist file in resources folder which was getting corrupted on build

Only one issue left.

Can you please tell me that is that necessary that we could get notification only on those devices which are registered to https://developer.apple.com/account/ios/device/