Instead of adding the code in didFinishLaunchingWithOptions(), consider adding it in your plugin's method (add the method if its missing):
- (void) pluginInitialize();
This code:
|
NSLog(@"initializing DBAccountManager"); |
|
DBAccountManager *accountManager = |
|
[[DBAccountManager alloc] initWithAppKey:@"irylk73l2cucd1v" secret:@"vw8ld6rdebdqayi"]; |
|
[DBAccountManager setSharedManager:accountManager]; |
|
|
|
DBAccount *account = [accountManager.linkedAccounts objectAtIndex:0]; |
|
if (account) { |
|
DBFilesystem *filesystem = [[DBFilesystem alloc] initWithAccount:account]; |
|
NSLog(@"App linked successfully from didFinishLaunchingWithOptions!"); |
|
[DBFilesystem setSharedFilesystem:filesystem]; |
|
} |
Can be in your plugin as:
- (void) pluginInitialize {
NSLog(@"initializing DBAccountManager");
DBAccountManager *accountManager =
[[DBAccountManager alloc] initWithAppKey:@"irylk73l2cucd1v" secret:@"vw8ld6rdebdqayi"];
[DBAccountManager setSharedManager:accountManager];
DBAccount *account = [accountManager.linkedAccounts objectAtIndex:0];
if (account) {
DBFilesystem *filesystem = [[DBFilesystem alloc] initWithAccount:account];
NSLog(@"App linked successfully from didFinishLaunchingWithOptions!");
[DBFilesystem setSharedFilesystem:filesystem];
}
}
Don't forget to add the required import headers as well at the top of your plugin.
#import <Dropbox/Dropbox.h>
From the Plugin Dev Guide: "There is no designated initializer for plugins. Instead, plugins should use the pluginInitialize method for their start-up logic."
Example use: https://github.com/apache/cordova-ios/blob/9e47ed817fdad4669a8ce92908eb63320dda593a/CordovaLib/Classes/CDVLocalStorage.m#L34-L41
To load the plugin at startup, you can add an:
... attribute to the feature's param tag: https://github.com/apache/cordova-ios/blob/951b6cb2f6d920b2cd28dd9598274331ad5a0d47/CordovaLibTests/CordovaLibApp/config.xml#L57
If you don't add that, the plugin is lazily loaded (load on first use).
Instead of adding the code in didFinishLaunchingWithOptions(), consider adding it in your plugin's method (add the method if its missing):
This code:
phonegap-dropbox-sync/plugin/src/ios/Classes/AppDelegate.m
Lines 70 to 80 in 682b333
Can be in your plugin as:
Don't forget to add the required import headers as well at the top of your plugin.
From the Plugin Dev Guide: "There is no designated initializer for plugins. Instead, plugins should use the pluginInitialize method for their start-up logic."
Example use: https://github.com/apache/cordova-ios/blob/9e47ed817fdad4669a8ce92908eb63320dda593a/CordovaLib/Classes/CDVLocalStorage.m#L34-L41
To load the plugin at startup, you can add an:
... attribute to the feature's param tag: https://github.com/apache/cordova-ios/blob/951b6cb2f6d920b2cd28dd9598274331ad5a0d47/CordovaLibTests/CordovaLibApp/config.xml#L57
If you don't add that, the plugin is lazily loaded (load on first use).