Private Sub Button1_Click
Dim avc As ActivityViewController
File.WriteString(File.DirTemp, "vcard.vcf", CreateVCard(36.4545, 32.2323))
Dim b() As Byte = CreateVCard(36.4545, 32.2323).GetBytes("utf8")
Dim ItemProvider As NativeObject
ItemProvider.Initialize("NSItemProvider").RunMethod("alloc", Null).RunMethod("initWithItem:typeIdentifier:", Array(ItemProvider.ArrayToNSData(b), "public.vcard"))
avc.Initialize("avc", Array(ItemProvider))
avc.Show(B4XPages.GetNativeParent(Me), Root) 'Second parameter is relevant for iPad only. The arrow will point to the view.
Wait For avc_Complete (Success As Boolean, ActivityType As String)
Log($"Success: ${Success}, ActivityType: ${ActivityType}"$)
End Sub
Sub CreateFileUrl (Dir As String, FileName As String) As Object
Dim no As NativeObject
no = no.Initialize("NSURL").RunMethod("fileURLWithPath:", Array(File.Combine(Dir, FileName)))
Return no
End Sub
Private Sub CreateVCard(Latitude As Double, Longitude As Double) As String
Return _
$"BEGIN:VCARD
VERSION:4.0
N:;Shared Location;;;
FN:Shared Location
item1.URL:http://maps.apple.com/?ll=${Latitude},${Longitude}
item1.X-ABLabel:map url
End:VCARD"$
End Sub