I have searched the internet about a code that fires the share sheet using foreign language, I have been successful so far to do that using for android but for IOS is kinda tricky, so here is the code and if someone can help me with the code or what I am doing wrong that would be nice.
The Code:
1- MainView.ux
var Share = require("Share");
function share() { Share.sendIntent(); }
module.exports = {
share: share
};
2-Share.uno
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
//[ForeignInclude(Language.ObjC, "apple.UIKit.UIActivityViewController")]
//[ForeignInclude(Language.ObjC, "com.fuse.Activity")]
[UXGlobalModule]
public class Share : NativeModule
{
static readonly Share _instance;
public Share()
{
// Make sure we're only initializing the module once
if(_instance != null) return;
_instance = this;
Resource.SetGlobalKey(_instance, "Share");
AddMember(new NativeFunction("sendIntent", (NativeCallback)SendIntent));
}
static object SendIntent(Context c, object[] args)
{
SendIntent();
return null;
}
[Foreign(Language.ObjC)]
static extern(iOS) void SendIntent()
@{
NSString *textToShare = [NSString stringWithFormat:@"www.google.com/%@",[[NjoftimeManager getSelectedListing] objectForKey:@"_id"]];
NSArray *itemsToShare = @[textToShare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities: nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //or whichever you don't need
[self presentViewController:activityVC animated:YES completion:nil];
@}
}
3- The error I am getting:
Share.uno(27.9): E3128: Call to 'Share.SendIntent(Fuse.Scripting.Context,object[])' has some invalid arguments ()
/Users/mostafa/Desktop/IOS Share/Share.uno(27,10,27,20): Error E3128: Call to 'Share.SendIntent(Fuse.Scripting.Context,object[])' has some invalid arguments ()
(1.6 s)
Build completed in 4.35 seconds
1 error
Build ended
fuse: Failed to compile project
I know it has failed because of something wrong with my SendIntent function but basically I just want this to work so if you know more than me which I know for sure you do, I need your help to finish this thanks in advance and happy new year.