iOS Question [Solved] Social Share

Discussion in 'iOS Questions' started by Descartex, Nov 9, 2016.

  1. Descartex

    Descartex Well-Known Member Licensed User

    Hi everybody!
    I'm trying to enable the social share feature for my app.
    I need to share an image and some text on Whatsapp, Facebook, Email, etc.
    I tried the code of this post:
    https://www.b4x.com/android/forum/t...elp-with-inline-objc.52849/page-6#post-336177
    but it only works when I choose an online file. If I try to send a local file, it raises an error i can not debug (I have no idea about ObjectiveC, sorry)
    Application_Start
    Application_Active
    Error occurred on line: 112 (modShare)
    *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]
    Stack Trace: (
    CoreFoundation <redacted> + 154
    libobjc.A.dylib objc_exception_throw + 38
    CoreFoundation <redacted> + 418
    CoreFoundation <redacted> + 44
    Share Test -[b4i_modshare share2SocialMedia:::::] + 1392
    CoreFoundation <redacted> + 68
    CoreFoundation <redacted> + 282
    Share Test +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
    Share Test -[B4INativeObject RunMethod::] + 158
    Share Test -[b4i_modshare _sharetosocialmedia:::::] + 2814
    Share Test -[b4i_main _cmdsharelocalimage_click] + 1540
    CoreFoundation <redacted> + 68
    CoreFoundation <redacted> + 282
    Share Test +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
    Share Test -[B4IShell runMethod:] + 574
    Share Test -[B4IShell raiseEventImpl:method:args::] + 1998
    Share Test -[B4IShellBI raiseEvent:event:params:] + 1442
    Share Test __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
    libdispatch.dylib <redacted> + 10
    libdispatch.dylib <redacted> + 22
    libdispatch.dylib <redacted> + 254
    CoreFoundation <redacted> + 8
    CoreFoundation <redacted> + 1300
    CoreFoundation CFRunLoopRunSpecific + 522
    CoreFoundation CFRunLoopRunInMode + 106
    GraphicsServices GSEventRunModal + 138
    UIKit UIApplicationMain + 1136
    Share Test main + 106
    libdyld.dylib <redacted> + 2
    )
    Can anyone help me to enable this feature?
    Thank you so much.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Descartex

    Descartex Well-Known Member Licensed User

    Yes, I used the code.
    Here you have my project.
    Thank you.
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    Your project as-is works fine here. I've tested it with SMS and Email.

    Try to uninstall the existing app and install it again.
     
  5. Descartex

    Descartex Well-Known Member Licensed User

    Sorry, but I uninstalled and installed this with no changes it still crashing when I choose local file...
    I've tried on Debug and Release Mode and both crash...
    As i said, with online file it works perfectly.
    If you look on the Error Log of my first post... it raises inside the objective C code... but I have no idea about objective C.

    Thank you.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Are you testing it on a real device?

    You can add log messages in the inline code to see where it crashes:
    Code:
    NSLog(@"1");
     
  7. Descartex

    Descartex Well-Known Member Licensed User

    Hi.
    Yes, I'm testing on real device...
    I was adding logs to the inline code and it crashes here:
    Code:
    NSLog(@"Here works");
    UIActivityViewController *controller =
    [[UIActivityViewController alloc]
    initWithActivityItems:@[text, url, 
    image]
    applicationActivities:nil];
    NSLog(@
    "Here crashes");
    Log shows this:
    Here works
    Error occurred on line: 124 (modShare)
    *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]
    Stack Trace: (
    CoreFoundation <redacted> + 154
    libobjc.A.dylib objc_exception_throw + 38
    CoreFoundation <redacted> + 418
    CoreFoundation <redacted> + 44
    Share Test -[b4i_modshare share2SocialMedia:::::] + 1550
    CoreFoundation <redacted> + 68
    CoreFoundation <redacted> + 282
    Share Test +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
    Share Test -[B4INativeObject RunMethod::] + 158
    Share Test -[b4i_modshare _sharetosocialmedia:::::] + 2814
    Share Test -[b4i_main _cmdsharelocalimage_click] + 1540
    CoreFoundation <redacted> + 68
    CoreFoundation <redacted> + 282
    Share Test +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
    Share Test -[B4IShell runMethod:] + 574
    Share Test -[B4IShell raiseEventImpl:method:args::] + 1998
    Share Test -[B4IShellBI raiseEvent:event:params:] + 1442
    Share Test __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
    libdispatch.dylib <redacted> + 10
    libdispatch.dylib <redacted> + 22
    libdispatch.dylib <redacted> + 254
    CoreFoundation <redacted> + 8
    CoreFoundation <redacted> + 1300
    CoreFoundation CFRunLoopRunSpecific + 522
    CoreFoundation CFRunLoopRunInMode + 106
    GraphicsServices GSEventRunModal + 138
    UIKit UIApplicationMain + 1136
    Share Test main + 106
    libdyld.dylib <redacted> + 2
    )

    Hope it helps.
    Thank you.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    One of the following values is null: text, url or image.
     
  9. Descartex

    Descartex Well-Known Member Licensed User

    For any reason, image is null...
    i tried to load to an imageview and it loads...
    maybe the inline code is wrong?
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    This is a mistake:
    Code:
    strImagePath = File.DirAssets & "/image.png"
    It should be:
    Code:
    strImagePath = File.Combine(File.DirAssets, "image.png")
     
  11. Descartex

    Descartex Well-Known Member Licensed User

    I've changed it and still crashing... image stills null.
     
  12. Descartex

    Descartex Well-Known Member Licensed User

    Here is the problem...
    Code:
    image = [UIImage imageNamed:theimg];
    I've changed it to:
    Code:
    image = [UIImage imageWithContentsOfFile:theimg];
    and worked...
    For any reason, the method ImageNamed is not working with assets folder.
    Thank you!!!
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    BTW, the inline code should have accepted an UIImage* instead of a string. The inline code (or library code) should only implement specific features and let developers use the standard methods for all other stuff.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice