You can use B4XPages.GetNativeParent(Me) to get the Page needed for sms.show.
Hi Erel, I tried using this code:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private hd As HUD
Private smsc As MessageComposer
End Sub
Public Sub Initialize
B4XPages.GetManager.TransitionAnimationDuration = 0
B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Private Sub Button1_Click
B4XPages.GetNativeParent(Me)
smsc.Initialize("smsc")
smsc.SetRecipients(Array As String("3331234567"))
smsc.Body = "Hello!!!"
smsc.Show(Me)
End Sub
Sub smsc_Complete (Result As Int)
If Result = smsc.RESULT_SENT Then
hd.ToastMessageShow("Message sent", True)
Else
hd.ToastMessageShow("Message was not sent", True)
End If
End Sub
but i have this error
Application_Start
*** mainpage: B4XPage_Created
Application_Active
*** mainpage: B4XPage_Appear [mainpage]
*** mainpage: B4XPage_Resize [mainpage]
Error occurred on line: 36 (B4XMainPage)
Expected: UIViewController, object type: b4i_b4xmainpage
Stack Trace: (
CoreFoundation 0551BAA3-C6E9-3423-B0E2-BE69719C1D7F + 1155832
libobjc.A.dylib objc_exception_throw + 88
CoreFoundation 0551BAA3-C6E9-3423-B0E2-BE69719C1D7F + 1543944
B4i Example -[B4IObjectWrapper setObject:] + 216
B4i Example +[B4IObjectWrapper createWrapper
bject:] + 92
B4i Example -[b4i_b4xmainpage _button1_click:] + 832
CoreFoundation 0551BAA3-C6E9-3423-B0E2-BE69719C1D7F + 201780
CoreFoundation 0551BAA3-C6E9-3423-B0E2-BE69719C1D7F + 204868
B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
B4i Example -[B4IShell runMethod:] + 420
B4i Example -[B4IShell raiseEventImpl:method:args::] + 1472
B4i Example -[B4IShellBI raiseEvent:event
arams:] + 1360
B4i Example __33-[B4I raiseUIEvent:event
arams:]_block_invoke + 52
libdispatch.dylib 2C7DB97B-46F0-3A67-AF9F-E26859F0008D + 6828
libdispatch.dylib 2C7DB97B-46F0-3A67-AF9F-E26859F0008D + 112004
libdispatch.dylib 2C7DB97B-46F0-3A67-AF9F-E26859F0008D + 230772
libdispatch.dylib 2C7DB97B-46F0-3A67-AF9F-E26859F0008D + 68912
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 0551BAA3-C6E9-3423-B0E2-BE69719C1D7F + 471732
CoreFoundation 0551BAA3-C6E9-3423-B0E2-BE69719C1D7F + 463024
CoreFoundation CFRunLoopRunSpecific + 572
GraphicsServices GSEventRunModal + 168
UIKitCore 05197341-F998-32E5-A847-DA98BB8C68BF + 3973696
UIKitCore UIApplicationMain + 336
B4i Example main + 100
dyld 189FE480-5D5B-3B89-9289-58BC88624420 + 68312
)
Please can you help me solve this problem?