• 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 DudeGuy · Nov 14, 2014 at 07:51 PM · pluginweb-player

Detect if Web Player is running in Facebook Canvas or not.

I'm using Facebook's official plugin for Unity, but it only works in Facebook Canvas or in the Editor. When running in a browser that is not in Facebook Canvas, it does not work. I'd like to be able to detect whether it is running in Facebook Canvas or not. The app depends on Facebook for a lot of t$$anonymous$$ngs, but I'd like it to still be able to run outside of Facebook Canvas for test purposes.

I first looked into adding an initFailure callback to the plugin, but it appears the methods under the hood that the plugin calls don't return failures back to Unity. I'd like to avoid dealing with a timeout or somet$$anonymous$$ng like that.

I also messed around with Application.absoluteUrl, but that only references the domain that is hosting the unity3d file, not whether it's running in Facebook Canvas or not.

Does anyone know of a way to detect t$$anonymous$$s?

Thanks for the help.

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

2 Replies

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

Answer by DudeGuy · Jan 15, 2015 at 07:14 PM

Just in case anyone else needs to do t$$anonymous$$s, I ended up using ExternalEval to get some information I needed. I'm not fully happy with t$$anonymous$$s implementation, but it's the cleanest way I can find without waiting for an arbitrary amount of time from the Facebook plugin.

First I try t$$anonymous$$s:

 Application.ExternalEval( "UnityObject2.instances[0].getUnity().SendMessage('GameObject', '_OnReferrerUrl', document.referrer);" );

And check for "https://apps.facebook.com" in the returned url.

If that doesn't contain the string, I then try:

 Application.ExternalEval( "UnityObject2.instances[0].getUnity().SendMessage('GameObject', '_OnUrl', document.URL);" );

And check for "https://integrated-plugin-canvas" in the url.

Make sure your callback methods take in a string as a parameter.

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
avatar image
1

Answer by Kiwasi · Nov 14, 2014 at 08:42 PM

Simply wait for FB.Init to call back. If you get no call back then assume you are not running on canvas.

How I typically manage it is not load any FaceBook functionality until the call back is received.

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 DudeGuy · Dec 11, 2014 at 09:41 PM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

27 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

Related Questions

Plugins in a Web Player 3 Answers

combining facebook with my game on both web player and standalone 0 Answers

Bug with EtceteraGUIManager.cs . 1 Answer

Which Android In app Purchase plugin should I choose? 0 Answers

Detecting a word clicked on in 3D text? 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