Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Crendel-Studios · May 02, 2017 at 01:16 PM · iosscreenshotsharingobjective-c

Native Sharing dialog cause crash on iPad 2 iOS 7.1.2

I'm working on Unity 5.6 mobile game. I'm using native share plugin https://github.com/ChrisMaire/unity-native-sharing to share game link with screenshot. It works like a charm on iPhone 7 with iOS 10, but crashes on iPad 2 with stack trace: Date/Time: 2017-04-27 20:50:44.908 +0300 OS Version: iOS 7.1.2 (11D257) Report Version: 104

 Exception Type:  EXC_CRASH (SIGABRT)
 Exception Codes: 0x0000000000000000, 0x0000000000000000
 Triggered by Thread:  0
 
 0   <unresolved>                      0x2ef46f7e <unresolved>
 1   <unresolved>                      0x39a2dcca <unresolved>
 2   <unresolved>                      0x2ef46ec0 <unresolved>
 3   <unresolved>                      0x319ade70 <unresolved>
 4   <unresolved>                      0x39a3cb66 <unresolved>
 5   mygame                            0x6bbcf0 -[iOSNativeShare initWithText:withURL:withImage:withSubject:] (iOSNativeShare.m:134)
 6   mygame                            0x6bb700 +[iOSNativeShare withText:withURL:withImage:withSubject:] (iOSNativeShare.m:51)
 7   mygame                            0x6bbdbc _showSocialSharing (iOSNativeShare.m:146)
 8   mygame                            0x72226 _NativeShare_showSocialSharing_m1817940662 (Bulk_Assembly-CSharp-firstpass_0.cpp:2766)
 9   mygame                            0x7211c _NativeShare_CallSocialShareAdvanced_m300608371 (Bulk_Assembly-CSharp-firstpass_0.cpp:2825)
 10  mygame                            0x72090 _NativeShare_Share_m4148598826 (Bulk_Assembly-CSharp-firstpass_0.cpp:2703)
 11  mygame                            0xd28a8 _U3CshowShareDialogU3Ec__IteratorF_MoveNext_m149489883 (Bulk_Assembly-CSharp_2.cpp:15675)
 12  mygame                            0x6940c8 RuntimeInvoker_Boolean_t211005341(MethodInfo const*, void*, void**) (Il2CppInvokerTable.cpp:935)
 13  mygame                            0xecdfa4 il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppObject**) (Runtime.cpp:350)
 14  mygame                            0x82300e ScriptingInvocation::Invoke(ScriptingException**, bool) (ScriptingInvocation.cpp:180)
 15  mygame                            0x822fa6 bool ScriptingInvocation::Invoke<bool>(ScriptingException**, bool) (ScriptingInvocation.cpp:131)
 16  mygame                            0x816a48 Coroutine::InvokeMoveNext(ScriptingException**) (ScriptingInvocation.h:46)
 17  mygame                            0x8168b6 Coroutine::Run() (Coroutine.cpp:226)
 18  mygame                            0x7293a6 DelayedCallManager::Update(int) (CallDelayed.cpp:178)
 19  mygame                            0x7e9ed8 PlayerLoop(bool, bool, IHookEvent*) (Player.cpp:1726)
 20  mygame                            0xa0148e UnityPlayerLoopImpl(bool) (LibEntryPoint.mm:239)
 21  mygame                            0x54028 _UnityRepaint (UnityAppController+Rendering.mm:236)
 22  mygame                            0x53e2c -[UnityAppController(Rendering) repaintDisplayLink] (UnityAppController+Rendering.mm:52)
 23  <unresolved>                      0x3142fdee <unresolved>
 24  <unresolved>                      0x3142fb98 <unresolved>
 25  <unresolved>                      0x3419d758 <unresolved>
 26  <unresolved>                      0x2fc3244c <unresolved>
 27  <unresolved>                      0x2ef06ea4 <unresolved>
 28  <unresolved>                      0x2ef11a62 <unresolved>
 29  <unresolved>                      0x2ef119fe <unresolved>
 30  <unresolved>                      0x2ef101d2 <unresolved>
 31  <unresolved>                      0x2ee7aeba <unresolved>
 32  <unresolved>                      0x2ee7ac9e <unresolved>
 33  <unresolved>                      0x33d7565e <unresolved>
 34  <unresolved>                      0x317c7148 <unresolved>
 35  mygame                            0x4c816 _main (main.mm:32)
 36  <unresolved>                      0x39f3aab2 <unresolved>

here is iOSNativeShare.m file: #import "iOSNativeShare.h"

 @implementation iOSNativeShare{
 }
 
 #ifdef UNITY_4_0 || UNITY_5_0
 
 #import "iPhone_View.h"
 
 #else
 
 extern UIViewController* UnityGetGLViewController();
 
 #endif
 
 +(id) withTitle:(char*)title withMessage:(char*)message{
     
     return [[iOSNativeShare alloc] initWithTitle:title withMessage:message];
 }
 
 -(id) initWithTitle:(char*)title withMessage:(char*)message{
     
     self = [super init];
     
     if( !self ) return self;
     
     ShowAlertMessage([[NSString alloc] initWithUTF8String:title], [[NSString alloc] initWithUTF8String:message]);
     
     return self;
     
 }
 
 void ShowAlertMessage (NSString *title, NSString *message){
     
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
                           
                           message:message
                           
                           delegate:nil
                           
                           cancelButtonTitle:@"OK"
                           
                           otherButtonTitles: nil];
     
     [alert show];
     
 }
 
 +(id) withText:(char*)text withURL:(char*)url withImage:(char*)image withSubject:(char*)subject{
     
     return [[iOSNativeShare alloc] initWithText:text withURL:url withImage:image withSubject:subject];
 }
 
 -(id) initWithText:(char*)text withURL:(char*)url withImage:(char*)image withSubject:(char*)subject{
     
     self = [super init];
     
     if( !self ) return self;
     
     
     
     NSString *mText = text ? [[NSString alloc] initWithUTF8String:text] : nil;
     
     NSString *mUrl = url ? [[NSString alloc] initWithUTF8String:url] : nil;
     
     NSString *mImage = image ? [[NSString alloc] initWithUTF8String:image] : nil;
     
     NSString *mSubject = subject ? [[NSString alloc] initWithUTF8String:subject] : nil;
     
     
     NSMutableArray *items = [NSMutableArray new];
     
     if(mText != NULL && mText.length > 0){
         
         [items addObject:mText];
         
     }
     
     if(mUrl != NULL && mUrl.length > 0){
         
         NSURL *formattedURL = [NSURL URLWithString:mUrl];
         
         [items addObject:formattedURL];
         
     }
     if(mImage != NULL && mImage.length > 0){
         
         if([mImage hasPrefix:@"http"])
         {
             NSURL *urlImage = [NSURL URLWithString:mImage];
             
             NSError *error = nil;
             NSData *dataImage = [NSData dataWithContentsOfURL:urlImage options:0 error:&error];
             
             if (!error) {
                 UIImage *imageFromUrl = [UIImage imageWithData:dataImage];
                 [items addObject:imageFromUrl];
             } else {
                 ShowAlertMessage(@"Error", @"Cannot load image");
             }
         }
         else if ( [self isStringValideBase64:mImage]){
             NSData* imageBase64Data = [[NSData alloc]initWithBase64Encoding:mImage];
             UIImage* image = [UIImage imageWithData:imageBase64Data];
             if (image!= nil){
                 [items addObject:image];
             }
             else{
                 ShowAlertMessage(@"Error", @"Cannot load image");
             }
         }
         else{
             NSFileManager *fileMgr = [NSFileManager defaultManager];
             if([fileMgr fileExistsAtPath:mImage]){
                 
                 NSData *dataImage = [NSData dataWithContentsOfFile:mImage];
                 
                 UIImage *imageFromUrl = [UIImage imageWithData:dataImage];
                 
                 [items addObject:imageFromUrl];
             }else{
                 ShowAlertMessage(@"Error", @"Cannot find image");
             }
         }
     }
     
     UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:Nil];
     
     if(mSubject != NULL) {
         [activity setValue:mSubject forKey:@"subject"];
     } else {
         [activity setValue:@"" forKey:@"subject"];
     }
     
     UIViewController *rootViewController = UnityGetGLViewController();
     //if iPhone
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
           [rootViewController presentViewController:activity animated:YES completion:Nil];
     }
     //if iPad
     else {
         // Change Rect to position Popover
         UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activity];
         [popup presentPopoverFromRect:CGRectMake(rootViewController.view.frame.size.width/2, rootViewController.view.frame.size.height/4, 0, 0)inView:rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
     }
     return self;
 }
 
 -(BOOL) isStringValideBase64:(NSString*)string{
     
     NSString *regExPattern = @"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$";
     
     NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil];
     NSUInteger regExMatches = [regEx numberOfMatchesInString:string options:0 range:NSMakeRange(0, [string length])];
     return regExMatches != 0;
 }
 
 # pragma mark - C API
 iOSNativeShare* instance;
 
 void showAlertMessage(struct ConfigStruct *confStruct) {
     instance = [iOSNativeShare withTitle:confStruct->title withMessage:confStruct->message];
 }
 
 void showSocialSharing(struct SocialSharingStruct *confStruct) {
     instance = [iOSNativeShare withText:confStruct->text withURL:confStruct->url withImage:confStruct->image withSubject:confStruct->subject];
 }
 
 @end


I'm trying to resolve this crash two days streight, but I have never worked with native iOS development and objective C and even can't figure out how to try\catch this exception and prevent game from crashing.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by thexdd · Jan 29, 2019 at 03:48 PM

Hi, did you manage to resolve it? I think I am having exact same problem...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to wait till the screenshot is saved? 1 Answer

Sharing image and text using objective c native code 1 Answer

Saving screenshot to photo roll with Prime31 0 Answers

Memory problem with UIImagePickerViewController 0 Answers

Call Unity class in XCode 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges