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 hulahoolgames · Dec 29, 2015 at 06:24 PM · facebooksharesocialsocial networking

How do apps post on walls without the actual login flow?

Some games like Crossy roads bring up the share dialog from facebook without actually ever having to redirect to fb app for permissions. How is this possible? Also how can you get the native iOS dialog that slides up when you want to share with options like "message/mail/fb/twitter" etc. Any insight on this is appreciated. Thanks!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by callen · Dec 29, 2015 at 07:36 PM

At some point you'll need to log in to use FB integration, but I'm guessing the FB SDK is able to save the fact that you logged in, so every app you authorize doesn't need to be individually logged into. I hear that today the only way to do any facebook interaction from an app is their SDK, which kinda sucks for app devs.

The non-FB sharing stuff is completely different, and platform-dependent. There are asset store packages for this, however the code is not very difficult.

I made iOS and Android plugins to do this stuff in about a day or two (half of that learning the ridiculous Obj-C syntax). It does involve a lot of pieces though, so instead of trying to dump a bunch of code here I'll tell you where to start your searches.

iOS

     UIActivityViewController* activityVC = [[UIActivityViewController alloc] 
            initWithActivityItems:postItems applicationActivities:nil];        
     [[[UIApplication sharedApplication] keyWindow].rootViewController 
            presentViewController:activityVC animated:YES completion:nil];    

Here, the main data variable is "postItems" which contains some text and an image. A lot of NSString headaches here though... basically, what you need to worry about here is getting the data between Objective-C and Unity.

Android Actually, I lied here and didnt make it a plugin. Instead I used Unity's JNI methods to call the few things I needed to do.

         readonly AndroidJavaObject CurAct = (new AndroidJavaClass("com.unity3d.player.UnityPlayer")).GetStatic<AndroidJavaObject>("currentActivity");
         readonly AndroidJavaClass IntentClass = new AndroidJavaClass("android.content.Intent");
 
         public void ShareMessage(string message)
         {
             Debug.Log("Android share text=" + message);
             var intent = buildShareIntent(message, null);
             presentWithChooser(intent);
         }
 
         void presentWithChooser(AndroidJavaObject intent)
         {
             var shareChooser = IntentClass.CallStatic<AndroidJavaObject>("createChooser", intent, "Share...");
             CurAct.Call("startActivity", shareChooser);
         }
         
         AndroidJavaObject buildShareIntent(string message, AndroidJavaObject uri)
         {
             AndroidJavaObject newIntent = new AndroidJavaObject("android.content.Intent", Intent_ACTION_SEND);
             //Set content type based on whether or not we got a URI
             newIntent.Call<AndroidJavaObject>("setType", uri == null ? MIME_TEXT : MIME_IMAGE);
             //Add the message and/or image data 
             if (uri != null) newIntent.Call<AndroidJavaObject>("putExtra", Intent_EXTRA_STREAM, uri);
             if (!string.IsNullOrEmpty(message)) newIntent.Call<AndroidJavaObject>("putExtra", Intent_EXTRA_TEXT, message);
             return newIntent;
         }

Notice that my buildShareIntent has a URI parameter? That's how I post an image, but dealing with the required file-permission stuff needed is beyond the scope of this response.

I'll just add this because it held me up a lot: to use a "FileProvider" you need an xml defining its path, and put that file at Assets/Plugins/Android/res/xml/myFileProviderPaths.xml, which you reference in your android manifest as android:resource="@xml/myFileProviderPaths". The details of all this are extensively covered on the web / S.O. as its a core part of Android app sharing.

Good luck!

Comment
Add comment · Show 1 · 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
avatar image hulahoolgames · Dec 29, 2015 at 08:06 PM 0
Share

Thanks a lot for the detailed explanation and the code examples. I have never developed unity plugins before, but will definitely look into it.

avatar image
1

Answer by ARKMs · Dec 29, 2015 at 07:36 PM

I recommend these two plugins:

https://github.com/is8r/unity-SocialPostPlugin This can share text without using the SDK or application of Facebook and Twitter, this use the integration that already contains iOS since version 6.0

https://github.com/ChrisMaire/unity-native-sharing And This, is for share text or screenshot With dialog share in iOS and Android

Comment
Add comment · Show 3 · 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
avatar image callen · Dec 29, 2015 at 07:47 PM 0
Share

Wish I had seen these before I built my own <_< but oh well I probably wouldn't understand them if not for doing it myself.

avatar image ARKMs callen · Dec 29, 2015 at 07:59 PM 0
Share

yeah, sometimes happens XD

avatar image hulahoolgames · Dec 29, 2015 at 08:07 PM 0
Share

@AR$$anonymous$$$$anonymous$$'s thanks a ton for linking these unity plugins. This is what I was looking for!

avatar image
0

Answer by ArshakKroyan · Dec 30, 2015 at 04:29 AM

Hi. Here is a good tutorial for sharing. http://www.theappguruz.com/blog/general-sharing-in-android-ios-in-unity

For more information you can search "IOS share Activity ".

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

36 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Facebook share for Webplayer. 2 Answers

Social media assets 1 Answer

Unity Facebook Invitation Notification? 0 Answers

Post to Facebook app using Application.OpenURL()? 1 Answer

Post Score to Facebook IOS 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