Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

iOS: Plugin does not start #404

Closed
kaynz opened this issue Dec 10, 2015 · 22 comments
Closed

iOS: Plugin does not start #404

kaynz opened this issue Dec 10, 2015 · 22 comments
Labels

Comments

@kaynz
Copy link

kaynz commented Dec 10, 2015

Trying to init PushNotification (after deviceready):

PushNotification.init({
     android: {senderID: 1234, iconColor: '#9dd442', icon: 'ic_stat_notification'},
     ios: {alert: true, badge: true, sound: true}
});

results to:

Can't find variable: PushNotification.

Setup: fresh installation of cordova-ios@3.9.2, phonegap-plugin-push (1.4.5)

Tried on iPhone 6s iOS 9.1 and iPhone 5 iOS 8.4.1 (both on UiWebView)

Other plugins:
plugins

xcode console output:

2015-12-10 11:34:01.372 [2007:2524478] DiskCookieStorage changing policy from 2 to 0,         cookie file: file:///private/var/mobile/Containers/Data/Application/976B8EE0-F292-4776-876D-    BCD76D9C0446/Library/Cookies/Cookies.binarycookies
2015-12-10 11:34:01.571 [2007:2524478] Apache Cordova native platform version 3.9.2 is     starting.
2015-12-10 11:34:01.575 [2007:2524478] Multi-tasking -> Device: YES, App: YES
2015-12-10 11:34:01.586 [2007:2524478] Unlimited access to network resources
2015-12-10 11:34:01.841 [2007:2524478] Starting Facebook Connect plugin
2015-12-10 11:34:01.842 [2007:2524478] [CDVTimer][facebookconnectplugin] 0.865042ms
2015-12-10 11:34:01.929 [2007:2524478] [CDVTimer][file] 87.269008ms
2015-12-10 11:34:01.931 [2007:2524478] [CDVTimer][googleplus] 0.431001ms
2015-12-10 11:34:01.932 [2007:2524478] [CDVTimer][keyboard] 0.652015ms
2015-12-10 11:34:02.233 [2007:2524478] [CDVTimer][splashscreen] 299.897969ms
2015-12-10 11:34:02.245 [2007:2524478] [CDVTimer][statusbar] 12.162983ms
2015-12-10 11:34:02.508 [2007:2524478] [CDVTimer][socialsharing] 262.291968ms
2015-12-10 11:34:02.662 [2007:2524478] [Crashlytics] Version 3.4.0 (92)
2015-12-10 11:34:02.737 [2007:2524478] [CDVTimer][crashlytics] 228.227973ms
2015-12-10 11:34:02.737 [2007:2524478] [CDVTimer][TotalPluginStartup] 896.835983ms
2015-12-10 11:34:03.356 [2007:2524478] Resetting plugins due to page load.
2015-12-10 11:34:03.471 [2007:2524478] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/0BCA2806-1CB7-4D08-88BB-7423887F425A/App.app/www/index.html
2015-12-10 11:34:03.485 [2007:2524478] Resetting plugins due to page load.
2015-12-10 11:34:03.496 [2007:2524478] Failed to load webpage with error: The requested URL was not found on this server.

Same setup works very good on android.

Any ideas?

@macdonst
Copy link
Member

@kaynz Did you wait for the deviceready event before calling the init method?

@kaynz
Copy link
Author

kaynz commented Dec 10, 2015

Yes.

@macdonst
Copy link
Member

@kaynz then it seems like something went wrong in the installation. Open the /platforms/ios folder and see if the push.js file got copied over correctly. Also, check to make sure that the platforms/ios has cordova_plugins.js has an entry for PushNotification as well.

@kaynz
Copy link
Author

kaynz commented Dec 10, 2015

Should it be exactly in /platforms/ios or any subdir? Can't find a Push.js in /platforms/ios

@macdonst
Copy link
Member

@kaynz the files would be at:

platforms/ios/www/plugins/phonegap-plugin-push/www/push.js
platforms/ios/www/cordova_plugins.js

@kaynz
Copy link
Author

kaynz commented Dec 10, 2015

Okay, got em. There is no phonegap-plugin-push folder in www/plugins. And there is no reference to push in cordova_plugins.js

@macdonst
Copy link
Member

@kaynz right so it seems like it never got installed for iOS which is weird in itself. Do:

cordova plugin rm phonegap-plugin-push
cordova plugin add phonegap-plugin-push

to force it to be installed. If that fixes your problem please close this issue.

@kaynz
Copy link
Author

kaynz commented Dec 10, 2015

Just noticed that Im getting following error at cordova plugin add phonegap-plugin-push:

Cannot find module 'cordova-common/src/ConfigParser/ConfigParser'

npm install cordova-common solved this. But got another bug, will post it in a few min.

@kaynz
Copy link
Author

kaynz commented Dec 10, 2015

Okay, the bug is as following:
If you platform rm/add, the plugin does not get installed.
If you plugin rm/add, the plugin gets installed.

@macdonst
Copy link
Member

@kaynz can you let me know exactly what version of cordova/phonegap you are using and the detailed steps to reproduce the issue? I want to see if this is a bug in Cordova CLI.

@kaynz
Copy link
Author

kaynz commented Dec 10, 2015

cordova 5.4.1
Steps:

cordova plugin add phonegap-plugin-push
cordova platform rm ios
cordova platform add ios

Should do it

@fredgalvao
Copy link
Collaborator

@macdonst By the way, metadata is now generated mainly to platforms/ios/platform_www/ instead of
platforms/ios/www/. It is only copied over after that from the former to the later.

Also, I'm pretty sure that's an issue with a bad installation of cordova by npm. Can you please try the following?

npm rm -g cordova
npm cache clean cordova
npm i -g cordova

@macdonst macdonst added retest and removed question labels Dec 10, 2015
@kaynz
Copy link
Author

kaynz commented Dec 11, 2015

I cleaned up:

npm rm -g cordova
npm cache clean cordova
rm -rf node_modules/*

Installed cordova:

npm install -g cordova

After that, I added ios platform:

App:hybrid App1$ cordova platform add ios
Adding ios project...
Running command: /Users/App1/.cordova/lib/npm_cache/cordova-ios/3.9.2/package/bin/create /Users/App1/App/hybrid/platforms/ios de.App App --cli
iOS project created with cordova-ios@3.9.2
Running command: /Users/App1/App/hybrid/hooks/after_prepare/010_add_platform_class.js /Users/App1/App/hybrid
add to body class: platform-ios
add to body class: platform-ios
Discovered plugin "SplashScreen" in config.xml. Installing to the project
Installing "com.borismus.webintent" for ios
Installing "cordova-plugin-camera" for ios
Installing "cordova-plugin-crosswalk-webview" for ios
Installing "cordova-plugin-device" for ios
Installing "cordova-plugin-device-motion" for ios
Installing "cordova-plugin-device-orientation" for ios    
Installing "cordova-plugin-disable-bitcode" for ios
Installing "cordova-plugin-facebook4" for ios
Installing "cordova-plugin-file" for ios
The Android Persistent storage location now defaults to "Internal". Please check this plugins README to see if you application needs any changes in its config.xml.  
If this is a new application no changes are required.    
If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:     
"<preference name="AndroidPersistentFileLocation" value="Compatibility" />"
to config.xml in order for the application to find previously stored files.
Installing "cordova-plugin-file-transfer" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
Installing "cordova-plugin-geolocation" for ios
Installing "cordova-plugin-globalization" for ios
Installing "cordova-plugin-googleplus" for ios
Installing "cordova-plugin-gpslocation" for ios
Installing "cordova-plugin-keyboard" for ios
Installing "cordova-plugin-media" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
Installing "cordova-plugin-network-information" for ios
Installing "cordova-plugin-shake" for ios
Dependent plugin "cordova-plugin-device-motion" already installed on ios.
Installing "cordova-plugin-splashscreen" for ios
Installing "cordova-plugin-statusbar" for ios
Installing "cordova-plugin-vibration" for ios
Installing "cordova-plugin-webserver" for ios
Installing "cordova-plugin-whitelist" for ios
Installing "cordova-plugin-x-socialsharing" for ios
Installing "org.apache.cordova.crashlytics" for ios

As you can see in the logs, the push plugin is fully ignored

Here is my fetch.json:

"phonegap-plugin-push": {
    "source": {
        "type": "registry",
        "id": "phonegap-plugin-push"
    },
    "is_top_level": true,
    "variables": {}
}

@nicoabie
Copy link

I think the problem is that you are not saving on the config.xml file when installing the plugin.
That's why when you rm/add platform it does not get installed.
Please try cordova plugin add phonegap-plugin-push --save

@kaynz
Copy link
Author

kaynz commented Dec 11, 2015

Okay, this

cordova plugin add phonegap-plugin-push --save

resulted into

<plugin name="phonegap-plugin-push" spec="~1.4.5"/>

in config.xml

But the plugin is still missing after platform rm/add.

@nicoabie
Copy link

It should say something in the log, an attempt to install it, if it is on the config.xml file.

@macdonst
Copy link
Member

@kaynz after you do a cordova build ios do you see the files copied into the platforms directory?

@kaynz
Copy link
Author

kaynz commented Dec 11, 2015

Files are still missing after cordova build ios =/

@kaynz
Copy link
Author

kaynz commented Dec 14, 2015

Interesting: If I run following on my windows machine, it's working: (previous was on mac)

cordova platform add ios

result:

Installing "phonegap-plugin-push" for ios

@nicoabie
Copy link

Something wrong with the plugins/ folder perhaps.
try the following please:

rm -rf plugins/
cordova platform rm ios
cordova platform add ios

@kaynz
Copy link
Author

kaynz commented Dec 17, 2015

Thanks.

rm -rf plugins/

worked. I can platform rm/add as much as I want now.

@kaynz kaynz closed this as completed Dec 17, 2015
@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

4 participants