The hooks in this repository are hooks that you can run during the packaging of your app. Ionic Package uses Cordova, so these are just standard Cordova Hooks that we've selected/accepted.
To run these hooks in Ionic Package, just put a <hook /> tag in your
config.xml, like this:
<hook type="after_prepare" src="package-hooks/add_platform_class.js" />That's it! Package will run that hook on the server.
This is probably one of the main reasons you're here, so this is how you do that:
-
Put the following in your
config.xml:<hook type="after_prepare" src="package-hooks/ios9_allow_http.sh" />
-
That's it, actually. Run
ionic package build ios ...again and your binary should allow HTTP.
You don't need to download these hooks locally, but local builds won't work without them.
To use them locally, you can clone the repository within your Ionic App, and
Cordova will pick up your <hook /> tags within config.xml automatically.
Within your app directory:
$ git clone https://github.com/ionic-team/ionic-package-hooks.git ./package-hooks
$ cd package-hooks
$ npm installThese are the available hooks. The type is what you put in type of your
<hook /> tag, unless you want to run the hook at a different stage (not
recommended). If you want a hook to run before another one, reorder the <hook /> tags.
- author: Ionic
- usage:
<hook type="after_prepare" src="package-hooks/add_platform_class.js" /> - function: Adds the various platform CSS classes to the
<body>tag of your app such asplatform-android,platform-ios, etc.
- author: @schmoofer/@dwieeb
- usage:
<hook type="after_prepare" src="package-hooks/android_custom_resources.js" /> - function: Copies assets in
resources/android/custom/to all drawable-* directories inplatforms/android/res. Asset filenames must only use a-z, 0-9, and underscores. Example application: Allows for custom icons to be used in Android notifications (action buttons and the notification icon) when using the Push plugin.
- author: @Just-Ghali
- usage:
<hook type="after_prepare" src="package-hooks/android_custom_values.js" /> - function: Copies style files from
resources/android/values/toplatforms/android/res/values. Adds the ability to add custom themes.xml and styles.xml to the res/values folder in the android build. - credit: @schmoofer/@dwieeb
- author: @carson-drake
- usage:
<hook type="after_prepare" src="package-hooks/android_ignore_translation_errors.js" /> - function: After Android prepare, add
build-extras.gradleto android platform root to allow android-lint to ignore the translation errors introduced when includingphonegap-plugin-barcodescanner.
- author: @rolandjitsu
- usage:
<hook type="after_prepare" src="package-hooks/copy_google_services_config_files.js" /> - function: Copy
google-services.jsonand/orGoogleService-Info.plistto Android/iOS platform specific required destinations to enable usage of cordova-plugin-firebase when the build is done in Ionic Cloud. Use @ionic/app-scripts to copy the config files inwwwat build time (this hook will search for them at that location).
- author: @daruwanov
- usage:
<hook type="after_prepare" src="package-hooks/ios9_allow_http.sh" /> - function: Sets
NSAllowsArbitraryLoadsto true in your.plistfile, allowing all regular HTTP connections in your app again for iOS9.
- author: @carson-drake
- usage:
<hook type="after_prepare" src="package-hooks/ios9_allow_native_fb.sh" /> - function: Deletes
LSApplicationQueriesSchemesand then reads the necessary listings to communicate with Facebook natively to the.plistfile, allowing login and other features to occur natively rather than in safari. - credit: @mablack
- author: @alongendler
- usage:
<hook type="after_prepare" src="package-hooks/ios9_allow_native_whatsapp.sh" /> - function: Adds
LSApplicationQueriesSchemesif needed and then adds the required key to communicate with whatsapp natively to the.plistfile, allowing to query the presence of WhatsApp on device using canOpenURL. - credit: @mablack, @carson-drake
- author: @akofman
- usage:
<hook type="after_prepare" src="package-hooks/ios_disable_bitcode.js" /> - function: Sets
ENABLE_BITCODEtoNOto fix iOS builds that stopped working afterphonegap-plugin-pushwas updated to 1.5.x.
- author: Ionic
- usage:
<hook type="after_prepare" src="package-hooks/ios_remove_armv7s.js" /> - function: Remove the
armv7sarchitecture from the build process, which causes various build errors, especially withcordova-plugin-facebook4.
- author: Iñaki Baz Castillo at eFace2Face, inc.
- usage:
<hook type="after_platform_add" src="package-hooks/iosrtc-swift-support.js" /> - function: Adds
swiftsupport by adding universal objective c bridge to project.
See CONTRIBUTING.md for details.