vstirbu / InstagramPlugin

Instagram plugin for PhoneGap/Cordova
MIT License
120 stars 77 forks source link

Error when sharing image to Instagram (iOS) #117

Open pjamourik opened 3 years ago

pjamourik commented 3 years ago

Is anyone else experiencing problems when sharing images to Instagram.

The problem only occurs on iOS, and only started about 1 or 2 weeks ago. Android works fine.

After selecting Instgram:

Schermafbeelding 2020-12-01 om 10 52 17

Coming back to my app, following error from the plugin shows:

Schermafbeelding 2020-12-01 om 10 53 24

Any feedback would be highly appreciated

atans2468 commented 3 years ago

I am having this issue as well, any update on resolution? I noticed that everything seems fine in iOS 14.0.1 but getting this error after updating to iOS 14.2

rodrigograca31 commented 3 years ago

Has Apple released a new version of iOS!? Is that the latest version of iOS? I'm not an iOS user or dev... cant help much but that might be a problem....

atans2468 commented 3 years ago

@rodrigograca31 yes it seems that they released iOS 14.2 and I'm no longer able to post due to this error when using this version. I can confirm that posting using version 14.0.1 is working though. I'm not an iOS dev either... @pjamourik did you find a work around for this?

pjamourik commented 3 years ago

Not really. I temporarily disabled the plug-in for iOS only.

I just download the image to the phone's library, copy the text to the clipboard and then open Instagram. The user then can select the image manually. Not great, but it works.

ensemblebd commented 3 years ago

Same, occurs on iPhone 11 @ > 14.0 < 14.4.1 14.4.1 works fine (iPhone 12).

Will reply if I find alternative or details of value. But so far it's a dead end.

Am reviewing this and this, and xcode logs to hopefully identify issue.

ensemblebd commented 3 years ago

I've found that different versions of IOS 14+ yield different results. On latest ios for me anyway, the document intent UTI system works perfectly well. Though having to find instagram in the list of apps is a pain.

But I have an alternative solution for the failing ios version. Am in progress working up a pull request after I clean it up and test more... I'm changing the code to give cordova's javascript a param (you) - the ability to control which approach to use. Instead of using ios version detection. That way if one fails, you can have your code call the other at will.

  1. Approach 1 (old logic: < 13.0) -- Use igo extension and Document Controller UTI of ".excusivegram"
  2. Approach 2 (old logic: >= 13.0) -- Use ig extension and Document Controller UTI of ".photo"
  3. Approach 3 (new) -- save base64 to Library, then launch app intent of instagram://library

The only solution I could come to, was to save the image as jpg to the Library, so as to generate a local identifier by scanning PHAsset, then launching /library intent. It works flawlessly on the failing ios version.

The only downsides:

So if you have a proprietary solution already in place for your app, to attain localIdentifiers from library, then you should just switch to the shareAsset function and call it a day. Otherwise, stay tuned for my git commit to feed base64 into library into instagram, as it were.

ensemblebd commented 3 years ago

if you wish to use it without pull request being processed, you can. But is at your own risk, it's working great for me, but recommend thoroughly reviewing the Objective C code to ensure it meets your own standards and is bug free to your view.

cordova plugin add https://github.com/ensemblebd/InstagramPlugin#5581fa220beda5071898ead5bc8e4d5423fa0b4b or meteor add cordova:cordova-instagram-plugin@https://github.com/ensemblebd/InstagramPlugin.git#5581fa220beda5071898ead5bc8e4d5423fa0b4b

rodrigograca31 commented 3 years ago

I just merged this and release as 0.6.2. Hopefully solves the problem.

swetanagur-salesfloor commented 1 year ago

I am still facing above issue on IOS 16, getting the above error when trying to post/message on Instagram Screen Shot 2023-05-02 at 10 54 58 AM

Here are the errors, that I traced from mac console, generated while recreating the above issue

1. Screen Shot 2023-05-04 at 10 25 57 AM

2. Screen Shot 2023-05-04 at 11 32 19 AM

3. Screen Shot 2023-05-04 at 11 34 17 AM

ensemblebd commented 1 year ago

Interesting. Looking online am seeing other reports listing it as a bug with apple (here, here). But has been a year since activity on the topic, so in theory apple has resolved it. The underlying case number was deleted by apple staff, so can't check (FB9793368).

Grep scanning for NSObject, am not seeing any in the core code of this plugin.
Are you able to post which version of cordova you have that it's compiling under? Also Gradle?

I'm using a Meteor project, so my cordova/gradle is always several versions behind everyone else. But for me it's not producing this issue; here's my version info for comparison:

swetanagur-salesfloor commented 1 year ago

IOS: 16.4 cordova-ios: 6.2.0 cordova:11.1.0

ensemblebd commented 1 year ago

Just updated my IOS to 13.3.1, and XCode to 14.3, but same Cordova as you (no change). For my mac-mini that's the highest I can upgrade to unfortunately, so I can't match your 16. Tested functional for my device: IPhone 12 and 13, with latest version of Instagram installed.

How does your config look? Like the callee that is. Mine is as such:

let base64='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QBg...';
let caption = 'captions no longer functional per instagram change; this does nothing';
let callback = (err) => {console.error(err);};

let mode = window.Instagram.SHARE_MODES.LIBRARY;
if (window.device && window.device.version) {
    var parts = window.device.version.split('.');
    let major = parts[0];
    if (major < 13) {
        mode = window.Instagram.SHARE_MODES.DEFAULT;
    }
}

window.Instagram.share(base64, caption, cb, mode);

(device is via: https://www.npmjs.com/package/cordova-plugin-device)

Also, check for any plugin logs in XCode developer tools. The plugin has it's own error log output. Very first thing you should see when the cordova plugin executes, via IsInstalled() self check, is: "IOS Version: 1.2.3" Followed by: "open in instagram", then "Using DEFAULT logic mode" if not specifying the Mode parameter above, and then by: "Saving temporary file under app specific folder", and then several different types of log outputs based on the Mode determined.

ie. If none of those messages are present, then the plugin isn't even executing; so something would have to be broken at a core level.

I'll look around and see if I can spot any reason why you'd get that error, but so far I can't replicate. Sorry not an easy answer yet.

swetanagur-salesfloor commented 1 year ago

The issue exists only for ios 16 and higher versions, I tried with ios 13 and ios 12 I cannot reproduce it

rodrigograca31 commented 1 year ago

I dont have have iOS devices, if someone comes up with a solution and sends a PR I can accept it tho

ensemblebd commented 1 year ago

Same here, and unfortunately I can't afford a 2022+ mac right now, so am hardware locked by Apple. Trying to find a way to get my hands on one, something in the cloud maybe for rental fee.

My coworker has ios 16.5 on his phone, and compilation from lower mac with xcode deployed live on appstore is working fully. So I believe this issue is related to the compilation in xcode (and not necessarily the ios phone it's deployed to).