Giter Site home page Giter Site logo

64bit support issue about aviarycordovaplugin HOT 3 OPEN

m1is avatar m1is commented on August 16, 2024
64bit support issue

from aviarycordovaplugin.

Comments (3)

m1is avatar m1is commented on August 16, 2024

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.

technicalboy86 avatar technicalboy86 commented on August 16, 2024

#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;

}

@EnD

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.

m1is avatar m1is commented on August 16, 2024

Submit a pull request so I can look at it.

from aviarycordovaplugin.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.