2 Replies Latest reply on Apr 18, 2014 10:04 PM by sharn jayantha

    how to invoke instagram with an existing picture?

    sharn jayantha

      hi guys,

       

      im trying to share a picture which taken in my rhomobile application through instagram.

      i use ios UIDocumentInteractionController functionality to open the picture in instagram. here is the code and in a native ios application its working perfectly.

       

       

      NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", igPath]];

      NSLog(@"URL Path %@", igImageHookFile);

       

      self.docFile = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];

      self.docFile.UTI = @"com.instagram.photo";

      [self.docFile setAnnotation:@{@"InstagramCaption" : @"#mymac"}];

       

      NSURL *instagramURL = [NSURL URLWithString:@"instagram:"];

      if ([[UIApplication sharedApplication] canOpenURL:instagramURL])

      {

          BOOL ret  = [self.docFile presentOpenInMenuFromRect: self.view.frame

                                           inView: self.view

                                         animated: NO ];


      // rhomobile version; since the native extension class is not inherited from UIViewContrlloer, had to get the view through shared application. (this version also works in ios native app)

      //    UIView *v = ((UIView*)[[[[UIApplication sharedApplication] keyWindow] subviews] lastObject]);

      //

      //    BOOL ret = [self.docFile presentOpenInMenuFromRect: v.frame

      //                                            inView: v

      //                                          animated: NO ];

       

            NSLog(@"ret ------ ;%d", ret); // both cases, logs 1 which means successful

      }

      else

      {

          NSLog(@"No Instagram Found");

      }


      what this code does is, it opens a menu to pick a application to open the file with (shown below)
      IMG_2314.PNG

       

      and here comes the question. in my rhomobile app i created a native extension method to execute this and the code execute with correct results but the menu does not appear. Any ideas on what's wrong with this? or is there any other approach to get this type of functionality in rhomobile?

       

      this is my native extension method stub.


      -(void) loadInstagram:(NSString*)image tags:(NSString*)tags methodResult:(id<IMethodResult>)methodResult {...}


      cheers!

        • Re: how to invoke instagram with an existing picture?
          Jon Tara

          Care to share you extension? We need the same functionality, and I wouldn't mind a running start! I'd be happy to collaborate on a GitHub project.

           

          Minor point, I think your extension method is mis-named. It doesn't really "load Instagram", does it? It loads whatever app the user chooses, which *might8 be Instagram.

           

          the code execute with correct results but the menu does not appear.

          Huh? How can it work "with correct results" if the menu never appears? Plus, you posted a picture of the menu!

            • Re: how to invoke instagram with an existing picture?
              sharn jayantha

              hi jon,

              Plus, you posted a picture of the menu!

               

              the attached menu is what expected and ONLY shows up in native ios project.

               

              Huh? How can it work "with correct results" if the menu never appears?

               

                i meant to say 'code executes with expected return values. for an example .... [self.docfile presentOpenInMenuFromRect:v.frame .....] should return 'true' if the presenting of the menu is successful which i get both cases but actually menu doesn't popup in the device in native extension version.

               

              and im happy to share the code.  sharn722/rhomobile_instagram · GitHub