IOS app setup: didFinishLaunchingWithOptions: method in a Cordova / Ionic project

I am new to Cordoba and I wonder if there is a way to customize the platform code created by Cordova / Ionic without interfering with the development process.

A specific requirement is the integration of the Facebook SDK into the iOS app to support ads on the Facebook Mobile App Install. The integration is simple: you only need to add a line of code for application:didFinishLaunchingWithOptions: in AppDelegate.m and add the iOS framework for iOS to the Xcode project.

Currently, the entire format catalog is excluded from the source control, as it is generated by Cordova during assembly. If I need to configure the AppDelegate.m application, I will have to add it to the original control. Then subsequent changes to the Ionic app will not lead to merge conflicts with the Xcode project? How can I integrate my small changes into an Xcode project without breaking the process?

NOTE: I was looking for a plugin as a solution, but the plugin found came

+6
source share
3 answers

You should create your own plugin instead of making changes to AppDelegate.m

You can listen to UIApplicationDidFinishLaunchingNotification on pluginInitialize , and enter the code there

 - (void)pluginInitialize { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil]; } - (void)finishLaunching:(NSNotification *)notification { // Put here the code that should be on the AppDelegate.m } 

The plugin.xml file needs the onload true function to call the pluginInitialize function

 <feature name="yourPluginName"> <param name="ios-package" value="yourPluginClass" /> <param name="onload" value="true" /> </feature> 
+12
source

You can use this plugin for this: https://github.com/katzer/cordova-plugin-app-event

+1
source

You can make additions to the application delegate file, this change will not disappear unlike the files inside the www-folder. You can make changes to the Xcode project folder.

0
source

Source: https://habr.com/ru/post/989603/


All Articles