I have found plenty of information on passing data from flutter to android using method channel but none for objective c. I understand calling functions, but not passing data. Below is an example of what I have.
Future<void> _uploadImage(String filePath) async {
try {
await platform.invokeMethod('uploadImage', {"filePath": filePath});
} on PlatformException catch (e) {
print("Failed to get token: '${e.message}'.");
}
}
else if([@"uploadImage" isEqualToString:call.method]){
DBUserClient *client = [DBClientsManager authorizedClient];
NSString *filePath = call.arguments(@"filePath");
NSLog(filePath, result);
NSData *fileData = [filePath dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
[[[client.filesRoutes uploadData:filePath inputData:fileData]
setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *networkError) {
if (result)
{
NSLog(@"%@\n", result);
} else
{
NSLog(@"%@\n%@\n", routeError, networkError);
}
}] setProgressBlock:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
}];
}
else{
result(FlutterMethodNotImplemented);
}
}];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
To clarify, the bottom set of code written in objective-c is definitely not correct, but I've been trying to piece it out. I have the images path and I am trying to upload it to Dropbox. Main issue is that the filePath is not reaching the method channel. NSString *filePath = call.arguments(@"filePath") isn't an actual function call.