Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/AirNativeShare.ane
Binary file not shown.
49 changes: 43 additions & 6 deletions ios/AirNativeShare.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
341A695A2A3FF0874EF5A33B /* libPods-AirNativeShare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD75BB790C32170CF2CEBB8 /* libPods-AirNativeShare.a */; };
700B6583250D7265007C9D44 /* libPods-AirNativeShare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 700B6581250D7255007C9D44 /* libPods-AirNativeShare.a */; };
A27464051F1F7BDF0072CE7F /* AirNativeShare.m in Sources */ = {isa = PBXBuildFile; fileRef = A27464041F1F7BDF0072CE7F /* AirNativeShare.m */; };
A27464061F1F7BDF0072CE7F /* AirNativeShare.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = A27464031F1F7BDF0072CE7F /* AirNativeShare.h */; };
A274640F1F1F7DAA0072CE7F /* FPANEUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = A274640E1F1F7DAA0072CE7F /* FPANEUtils.m */; };
Expand All @@ -30,6 +30,7 @@
/* Begin PBXFileReference section */
3682DAD08447EB0E61EF5FD9 /* Pods-AirNativeShare.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirNativeShare.release.xcconfig"; path = "Pods/Target Support Files/Pods-AirNativeShare/Pods-AirNativeShare.release.xcconfig"; sourceTree = "<group>"; };
3A4B35C90CDC4C8587A0D386 /* Pods-AirNativeShare.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirNativeShare.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AirNativeShare/Pods-AirNativeShare.debug.xcconfig"; sourceTree = "<group>"; };
700B6581250D7255007C9D44 /* libPods-AirNativeShare.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libPods-AirNativeShare.a"; sourceTree = "<group>"; };
A27464001F1F7BDE0072CE7F /* libAirNativeShare.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAirNativeShare.a; sourceTree = BUILT_PRODUCTS_DIR; };
A27464031F1F7BDF0072CE7F /* AirNativeShare.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AirNativeShare.h; sourceTree = "<group>"; };
A27464041F1F7BDF0072CE7F /* AirNativeShare.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AirNativeShare.m; sourceTree = "<group>"; };
Expand All @@ -47,7 +48,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
341A695A2A3FF0874EF5A33B /* libPods-AirNativeShare.a in Frameworks */,
700B6583250D7265007C9D44 /* libPods-AirNativeShare.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -99,6 +100,7 @@
BC69B8ED064769C96FA2317B /* Frameworks */ = {
isa = PBXGroup;
children = (
700B6581250D7255007C9D44 /* libPods-AirNativeShare.a */,
AAD75BB790C32170CF2CEBB8 /* libPods-AirNativeShare.a */,
);
name = Frameworks;
Expand Down Expand Up @@ -132,7 +134,7 @@
A27463F81F1F7BDE0072CE7F /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1150;
ORGANIZATIONNAME = "Mateo Kozomara";
TargetAttributes = {
A27463FF1F1F7BDE0072CE7F = {
Expand All @@ -144,10 +146,11 @@
};
buildConfigurationList = A27463FB1F1F7BDE0072CE7F /* Build configuration list for PBXProject "AirNativeShare" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = A27463F71F1F7BDE0072CE7F;
productRefGroup = A27464011F1F7BDE0072CE7F /* Products */;
Expand Down Expand Up @@ -210,21 +213,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -247,32 +259,42 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
A27464081F1F7BDF0072CE7F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -289,9 +311,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -301,9 +324,16 @@
baseConfigurationReference = 3A4B35C90CDC4C8587A0D386 /* Pods-AirNativeShare.debug.xcconfig */;
buildSettings = {
DEVELOPMENT_TEAM = HWKC8H7H6U;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -312,9 +342,16 @@
baseConfigurationReference = 3682DAD08447EB0E61EF5FD9 /* Pods-AirNativeShare.release.xcconfig */;
buildSettings = {
DEVELOPMENT_TEAM = HWKC8H7H6U;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
125 changes: 117 additions & 8 deletions ios/AirNativeShare/AirNativeShare.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,33 @@ - (void) sendEvent:(NSString*)code level:(NSString*)level {
}

[controller sendLog:[@"Sharing now... : " stringByAppendingString:@""]];
UIViewController* rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];

//UIViewController* rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

UIActivityViewController* activityViewController =[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )

//[UIDevice userInterfaceIdiom];
//if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
if ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad )
{
activityViewController.popoverPresentationController.sourceView = rootViewController.view;
[controller sendLog:[@"is iPad ..... : " stringByAppendingString:@""]];

if( [activityViewController respondsToSelector:@selector(popoverPresentationController)] )
{
// CGRect popOverRect = CGRectMake(50, 150, 100, 100); //[self getRectFromOptions:freOptions];
// activityViewController.popoverPresentationController.sourceView = [rootViewController view];
// activityViewController.popoverPresentationController.sourceRect = popOverRect;

activityViewController.popoverPresentationController.sourceView = [[[[UIApplication sharedApplication] delegate] window] rootViewController].view;
activityViewController.popoverPresentationController.sourceRect = CGRectMake(0,20, 0, 0);

UIPopoverArrowDirection direction = 0; //[self getArrowDirectionFromOptions:freOptions];
if( direction == UIPopoverArrowDirectionUnknown )
{
direction = 0; // No arrow
}
activityViewController.popoverPresentationController.permittedArrowDirections = direction;
}
}

[activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
Expand Down Expand Up @@ -139,13 +159,33 @@ - (void) sendEvent:(NSString*)code level:(NSString*)level {


[controller sendLog:[@"Custom sharing now... : " stringByAppendingString:@""]];
UIViewController* rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];

// UIViewController* rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
UIViewController* rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

UIActivityViewController* activityViewController =[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
//if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
if ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad )

{
activityViewController.popoverPresentationController.sourceView = rootViewController.view;
[controller sendLog:[@"is iPad ..... : " stringByAppendingString:@""]];

if( [activityViewController respondsToSelector:@selector(popoverPresentationController)] )
{
// CGRect popOverRect = CGRectMake(50, 150, 100, 100); //[self getRectFromOptions:freOptions];
// activityViewController.popoverPresentationController.sourceView = [rootViewController view];
// activityViewController.popoverPresentationController.sourceRect = popOverRect;

activityViewController.popoverPresentationController.sourceView = [[[[UIApplication sharedApplication] delegate] window] rootViewController].view;
activityViewController.popoverPresentationController.sourceRect = CGRectMake(0,20, 0, 0);


UIPopoverArrowDirection direction = 0; //[self getArrowDirectionFromOptions:freOptions];
if( direction == UIPopoverArrowDirectionUnknown )
{
direction = 0; // No arrow
}
activityViewController.popoverPresentationController.permittedArrowDirections = direction;
}
}

[activityViewController setCompletionWithItemsHandler:^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
Expand All @@ -167,6 +207,74 @@ - (void) sendEvent:(NSString*)code level:(NSString*)level {
return nil;
}

DEFINE_ANE_FUNCTION(shareToStory) {

AirNativeShare* controller = GetAirNativeShareContextNativeData(context);

if (!controller)
return AirNativeShare_FPANE_CreateError(@"context's AirNativeShare is null", 0);

@try {

NSString *appId = AirNativeShare_FPANE_FREObjectToNSString(argv[0]);
UIImage* image = AirNativeShare_FPANE_FREBitmapDataToUIImage(argv[1]);
NSString *provider = AirNativeShare_FPANE_FREObjectToNSString(argv[2]);

NSData *imageData = UIImagePNGRepresentation(image);
NSString *urlString = nil;
if([provider isEqualToString:@"facebook"]) {
urlString = @"facebook-stories://share";
}
else { //if ([provider isEqualToString:@"instagram"])
urlString = [@"instagram-stories://share?source_application=" stringByAppendingString:appId];
}

// Verify app can open custom URL scheme, open if able
NSURL *urlScheme = [NSURL URLWithString:urlString];

if ([[UIApplication sharedApplication] canOpenURL:urlScheme]) {

// Assign background image asset to pasteboard
NSArray *pasteboardItems = nil;
if([provider isEqualToString:@"facebook"]) {
pasteboardItems = @[@{
@"com.facebook.sharedSticker.appID" : appId,
@"com.facebook.sharedSticker.backgroundImage" : imageData
}];
}
else { //if ([provider isEqualToString:@"instagram"])
pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundImage" : imageData}];
}


NSDictionary *pasteboardOptions = @{UIPasteboardOptionExpirationDate : [[NSDate date] dateByAddingTimeInterval:60 * 5]};
// This call is iOS 10+, can use 'setItems' depending on what versions you support
[[UIPasteboard generalPasteboard] setItems:pasteboardItems options:pasteboardOptions];

[[UIApplication sharedApplication] openURL:urlScheme options:@{} completionHandler:^(BOOL success) {
if(success) {
[controller sendEvent:kAirNativeShareEvent_didShare];
}
else {
[controller sendEvent:kAirNativeShareEvent_cancelled];
}
}];

} else {
// Handle older app versions or app not installed case
[controller sendLog:@"Cannot open facebook"];
[controller sendEvent:kAirNativeShareEvent_cancelled];
}

}
@catch (NSException *exception) {
[controller sendLog:[@"Exception occured while trying to share : " stringByAppendingString:exception.reason]];
}


return nil;
}

#pragma mark - ANE setup

void AirNativeShareContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx,
Expand All @@ -178,6 +286,7 @@ void AirNativeShareContextInitializer(void* extData, const uint8_t* ctxType, FRE
static FRENamedFunction functions[] = {
MAP_FUNCTION(showShareDialog, NULL),
MAP_FUNCTION(showShareWithCustomTexts, NULL),
MAP_FUNCTION(shareToStory, NULL)
};

*numFunctionsToTest = sizeof(functions) / sizeof(FRENamedFunction);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added ios/build/Debug-iphoneos/libPods-AirNativeShare.a
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies: \
/Users/emmanuelgomez/Documents/GitHub/ANE-NativeShare/ios/Pods/Target\ Support\ Files/Pods-AirNativeShare/Pods-AirNativeShare-dummy.m
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/emmanuelgomez/Documents/GitHub/ANE-NativeShare/ios/build/Pods.build/Debug-iphoneos/Pods-AirNativeShare.build/Objects-normal/arm64/Pods-AirNativeShare-dummy.o
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies: \
/Users/emmanuelgomez/Documents/GitHub/ANE-NativeShare/ios/Pods/Target\ Support\ Files/Pods-AirNativeShare/Pods-AirNativeShare-dummy.m
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/emmanuelgomez/Documents/GitHub/ANE-NativeShare/ios/build/Pods.build/Debug-iphoneos/Pods-AirNativeShare.build/Objects-normal/armv7/Pods-AirNativeShare-dummy.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"case-sensitive":"false","roots":[],"version":0}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"case-sensitive":"false","roots":[],"version":0}
Binary file not shown.
Loading