1
votes

I need to create custom plugin that will add entries to info.plist for cordova/angular4 iOS application. (In this case exit application if home button pressed)

I need to add row:

<key>UIApplicationExitsOnSuspend</key>
<true/>

Here is the content of plugin I wrote (which may be not correct, because I couldn't test it).

<config-file target="*-Info.plist" platform="ios" parent="UIApplicationExitsOnSuspend">
<array>
  <boolean><true/></boolean>
</array>
</config-file>

What is needed to 'import' this plugin to config.xml and so that every time I do cordova build ios plist file will have entries I need?

I've read this posts and I didn't understood how it's done.

Add entry to iOS .plist file via Cordova config.xml

Cordova: Modifying *-Info.plist from plugin.xml

2

2 Answers

4
votes

After couple of hours of search and few attempts it was actually enough to just add:

<config-file target="*-Info.plist"parent="UIApplicationExitsOnSuspend">
    <true/>
</config-file>

(which in my case prevents application from running in the background)

right into config.xml and nest it inside <platform name="ios"> tag as if it was your plugin. And this setting will be added to *-info.plist during cordova build ios without any need to manually install your custom plugin.

Hint: I was firstly mistaken that instead of * in target="*-Info.plist" there has to be your app's title, but as it happens there actually has to be a * symbol and cordova itself will figure out the name of info.plist for you application.

1
votes

You should add this configuration in plugin.xml.

Inside the ios platform add below lines of code:

<platform name="ios">
    <config-file target="*-Info.plist" parent="UIApplicationExitsOnSuspend">
      <true/>
    </config-file>
 </platform> 

Let me know how it works.