Comments (3)
I would think the plugin's code is agnostic and you just compile it for the platform you're running it on. However I'm not sure about 64 bit support for this particular version of the Aviary SDK used for this plugin, maybe check that.
from aviarycordovaplugin.
#import "Aviary.h"
#import <Cordova/CDVPlugin.h>
#import <AviarySDK/AviarySDK.h>
@implementation Aviary
@synthesize aviary;
@synthesize pluginCallbackId;
@synthesize quality;
@synthesize originalImageURI;
-
(void) prepareForShow:(CDVInvokedUrlCommand_) command
{
[AFOpenGLManager beginOpenGLLoad];
CDVPluginResult_ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
} -
(void) show:(CDVInvokedUrlCommand*) command
{
pluginCallbackId = command.callbackId;originalImageURI = [command.arguments objectAtIndex:0];
NSURL* url = [NSURL URLWithString:originalImageURI];
NSString* imagePath = [url path];
UIImage* image = [UIImage imageWithContentsOfFile:imagePath];quality = [command.arguments objectAtIndex:2];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[AVYPhotoEditorController setAPIKey:@"APIKEY" secret:@"SECRET"];
});AVYPhotoEditorController *editorController = [[AVYPhotoEditorController alloc] initWithImage:image];
[editorController setDelegate:self];
[self.viewController presentViewController:editorController animated:YES completion:nil];
//[self.viewController presentModalViewController:self.aviary animated:YES];
}
-(void) photoEditor:(AVYPhotoEditorController *)editor finishedWithImage:(UIImage *)image
{
if (!editor.session.isModified) {
[self returnSuccess:originalImageURI];
[self closeAviary];
return;
}
BOOL ok = false;
NSString * res = @"error";
BOOL saveToPhotoAlbum = YES;
NSData* data = nil;
data = UIImageJPEGRepresentation(image , (quality ? ([quality floatValue] / 100) : 0.9f));
// write to temp directory and reutrn URI
// get the temp directory path
NSString* docsPath = [NSTemporaryDirectory() stringByStandardizingPath];
NSError* err = nil;
NSFileManager* fileMgr = [[NSFileManager alloc] init];
// generate unique file name
NSString* filePath;
int i=1;
do
{
filePath = [NSString stringWithFormat:@"%@/photo_%03d.%@", docsPath, i++, @"jpg"];
}
while([fileMgr fileExistsAtPath: filePath]);
// save file
if (![data writeToFile: filePath options: NSAtomicWrite error: &err])
{
res = @"error saving file";
}
else
{
res = [[NSURL fileURLWithPath: filePath] absoluteString];
ok = true;
}
if(ok)
{
if (saveToPhotoAlbum )
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
[self returnSuccess:res];
}
else
{
[self returnError:res];
}
[self.viewController dismissViewControllerAnimated:YES completion:nil];
}
-(void) photoEditorCanceled:(AFPhotoEditorController *)editor
{
//[self closeAviary];
[self.viewController dismissViewControllerAnimated:YES completion:nil];
}
-(void) returnSuccess:(NSString_)imagePath
{
NSString_ filename = [imagePath lastPathComponent];
NSMutableDictionary* dict = [[NSMutableDictionary alloc]init];
[dict setObject:imagePath forKey:@"src"];
[dict setObject:filename forKey:@"name"];
CDVPluginResult* result = [CDVPluginResult
resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:dict];
NSString* javaScript = [result toSuccessCallbackString:self.pluginCallbackId];
[self writeJavascript:javaScript];
}
-(void) returnError:(NSString_)message
{
CDVPluginResult_ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
NSString* javaScript = [result toSuccessCallbackString:self.pluginCallbackId];
[self writeJavascript:javaScript];
}
-(void) closeAviary
{
[self.aviary dismissModalViewControllerAnimated:YES];
self.aviary.delegate = nil;
self.aviary = nil;
}
I changed your Aviary.m like this. and then it works for me.
I would like you to update your code with latest AviarySDK.
Best Regards.
from aviarycordovaplugin.
Submit a pull request so I can look at it.
from aviarycordovaplugin.
Related Issues (13)
- Integration of plugin with both ios and android HOT 3
- aviary not running HOT 3
- How to setup the apikey/secret for aviary sdk 4.3
- Plugin fail on Android HOT 10
- Plugin Causes app to crash under Android L (5.0) HOT 1
- Aviary Key and Secret
- Failed install the plugin because the plugin trying to override existing res folder on android. HOT 1
- missing exec:Aviary.show HOT 4
- Aviary photo editor does not appear on iOS7 HOT 4
- Failing on Cordova 3.3? HOT 3
- Quality argument not handled properly in iOS HOT 2
- plugin should return original image if unmodified (when possible)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aviarycordovaplugin.