Skip to content

Commit

Permalink
Add support for an app:// (macOS)
Browse files Browse the repository at this point in the history
  • Loading branch information
katzer committed Jun 26, 2017
1 parent d937e48 commit d43992c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#### Version 0.8.7 (not yet released)
- Add support for an app:// URL #158 (Android)
- Add support for an app:// (iOS)
- Add support for an app:// (iOS, macOS)

#### Version 0.8.6 (12.06.2017)
- Fixed issue with Android 4.x
Expand Down
25 changes: 25 additions & 0 deletions src/osx/APPEmailComposerImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ - (NSArray*) getAttachments:(NSArray*)attatchments
{
return [self urlForAsset:path];
}
else if ([path hasPrefix:@"app://"])
{
return [self urlForAppInternalPath:path];
}
else if ([path hasPrefix:@"base64:"])
{
return [self urlFromBase64:path];
Expand Down Expand Up @@ -316,6 +320,27 @@ - (NSArray*) getAttachments:(NSArray*)attatchments
return [NSURL fileURLWithPath:absPath];
}

/**
* Retrieves the file URL for an internal app path.
*
* @param path A relative file path from main bundle dir.
*
* @return The URL for the internal path.
*/
- (NSURL<NSPasteboardWriting>*) urlForAppInternalPath:(NSString*)path
{
NSFileManager* fm = [NSFileManager defaultManager];

NSBundle* mainBundle = [NSBundle mainBundle];
NSString* absPath = [mainBundle bundlePath];

if (![fm fileExistsAtPath:absPath]) {
NSLog(@"File not found: %@", absPath);
}

return [NSURL fileURLWithPath:absPath];
}

/**
* Retrieves the data for a base64 encoded string.
*
Expand Down

0 comments on commit d43992c

Please sign in to comment.