Wednesday 4 November 2015

Twitter- Deep Linking with Android

Twitter - Deep Linking for Mobile Developers

The App Card provides the ability for users to download your app (if the user doesn’t already have it installed), or deep-link into your own app (if the app is already installed on the user’s mobile device).
We can achieve this things with Twitter Card.

https://dev.twitter.com/cards/mobile

We need to make dynamic Web page and host this page on any server which will be use for Sharing using Twitter from app. 

For demonstration purpose, we have implemented the same functionality in PHP with some hard-coded data but you need to convert in your back-end technology with dynamic data.

Please find PHP source code which we used for testing purpose.

Web Page Part
<html>
<head> 
<title>App Name</title>
<meta name="twitter:card" content="summary">

<meta name="twitter:site" content="App Name">
<meta name="twitter:title" content="App Name">

<meta name="twitter:description" content="App Name is a 100% free social sharing app that allows sharing of video, photo, audio and text all in one network.">
<meta name="twitter:image" content="http://app_name.vm39.sa92.info/ico.png">
<meta name="twitter:url" content="http://appname.com/">
<meta name="twitter:app:name:iphone" content="appname"/>
<meta name="twitter:app:id:iphone" content="570281083"/>
<meta name="twitter:app:name:googleplay" content="appname"/>
<meta name="twitter:app:id:googleplay" content="com.appname"/>
<meta name="twitter:app:url:iphone" content="appname://show?bid=54e58b4360afd71a53001f5e" />
<meta name="twitter:app:url:googleplay" content="appname://show?bid=54e58b4360afd71a53001f5e" />
</head>
<body>
<h1>Have something interesting here for particular Post, becasue when user click on link from Twitter it he/she will come to this page.</h1>
</body>
</html>

We have used summary card here.
https://dev.twitter.com/cards/types/summary
https://dev.twitter.com/cards/types/app

After making card, you have to validate your card with below URL.
https://cards-dev.twitter.com/validator

Android Part

At Android side, we need to do below things.
We need to add host and scheme in activity tag of Manifest file based on url defined in twitter app link url above.

Please find below code snippets below for reference.

AndroidManifest.xml

 <activity

            android:name=".ui.activities.SplashActivity"

            android:label="@string/app_name"

            android:launchMode="singleTop"

            android:screenOrientation="sensorPortrait"

            android:windowSoftInputMode="adjustResize" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

            <intent-filter android:label="@string/app_name" >

                <action android:name="android.intent.action.VIEW" >
                </action>
                <category android:name="android.intent.category.DEFAULT" >
                </category>
                <category android:name="android.intent.category.BROWSABLE" >
                </category>


                <!-- Accepts URIs that begin with "example://action" -->

                <data

                    android:host="show"
                    android:scheme="appname" >

                </data>

            </intent-filter>
        </activity> 



In Activity, You can retrieve app link url in oncreate() method.
With url, you can redirect user to our app's screen based on data retrieved from URL.

Please find below code snippets below for reference.

onCreate() 
if (getIntent().getData() != null

                && getIntent().getData().toString().length() > 0) {


            Logs.e(TAG, "Data:" + getIntent().getData());

        if (getIntent().getData().toString().startsWith("appname")) {


                twitterCallbackUrl = getIntent().getData().toString()
                        .substring(getIntent().getData().toString().lastIndexOf("?bid=") + 5,
                                getIntent().getData().toString().length());



                Logs.e(TAG, "twitterCallbackUrl:" + twitterCallbackUrl);
            }
        }




 
 

48 comments:

  1. Perfect!!! What I can say in this article is very important to be written as it may help everybody to get awareness. Good job done.Android Training in Noida

    ReplyDelete
  2. Perfect!!! What I can say in this article is very important to be written as it may help everybody to get awareness. Good job done.Android Training in Noida

    ReplyDelete

  3. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.

    Online Reputation Management

    ReplyDelete
  4. Awesome informative article..Thank you Ankit..Nice stuff ! But it is not passing data through scheme properly .
    Mobile App Development Company in Jaipur

    ReplyDelete

  5. Thank you for the info. It sounds pretty user friendly. I guess I’ll pick one up for fun. thank u

    Android App Development Training in Chennai

    ReplyDelete
  6. Hi... Ankit.. I have read your blog and it is like others of your great blogs. You always write an impressive post. A fabulous blog.
    ANDROID TRAINING IN NOIDA

    ReplyDelete
  7. It is nice post and I found some interesting information on this blog, keep it up. Thanks for sharing.

    Android App Development

    ReplyDelete
  8. hi Ankit Thakkar thanks for sharing Twitter- Deep Linking with Android concept. very interesting topic for sharing.keep sharing on andriod updated tutorials.......

    ReplyDelete
  9. A very well-written post. I read and liked the post and have also bookmarked you. All the best for future endeavors. Getting some solution regarding.
    UI Designing Company in Bangalore, Web Application Development Companies in Bangalore

    ReplyDelete
  10. Good Information I like this blogs Techavera Noida Also provides Android Training in Noida.

    ReplyDelete

  11. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai





    ReplyDelete
  12. Nice one..very useful for an individual web designers or any web designing company as well. I think if I am not wrong, it would be worth enough for all web design companies

    ReplyDelete
  13. Twigs Technologies is a leading company in the development of applications for Android. Development of Android applications Being the core of today's mobile strategy, we are helping global companies develop and implement the best Android class applications to keep them before the curve. Not only do we develop excellent Android applications, but we also support it in terms of marketing and monetization applications. With a ready-to-use framework and a strong team of Android application developers, we are rapidly developing the application and deploying the project according to the planned schedule.
    Android App Development in Gurgaon

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. This is very informative blog check it once through Android Online Training Bangalore for more information on android development.

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much web desgin company in chennai

    ReplyDelete
  18. Australia Best Tutor is offer excellent my assignment help to the students. The quality of the Management Assignment Help Tasmania provided by them is truly exceptional.

    Read More @

    My Assignment Help NSW
    Management Assignment Help Tasmania

    Live Chat @

    https://www.australiabesttutor.com/management-project-assignment-help

    ReplyDelete
  19. My Genius Mind is a renowned academic portal that offers impressive academic support to the students.
    Live Chat @ https://www.mygeniusmind.com/
    Read More @
    Western Australia Assignment Help
    Writing Services Melbourne
    Australia Best Tutor
    Hobart Tasmania Assignment Help

    ReplyDelete

  20. I am really happy with your blog because your article is very unique and powerful for new reader.
    Click here:
    Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune | Selenium online Training

    ReplyDelete
  21. Thank you for your informative post keep sharing the valuable information like this..


    Digital marketing companies in bangalore | Mobile app development companies in bangalore

    ReplyDelete
  22. hi, great post. It was really useful to read your blog. Thanks for it, keep updating!

    DevOps Online Training

    ReplyDelete
  23. After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience. Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in
    python Online training in chennai
    python Online training in bangalore
    python interview question and answers

    ReplyDelete
  24. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    rpa training in bangalore
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    rpa training in chennai

    ReplyDelete
  25. This is quite educational arrange. It has famous breeding about what I rarity to vouch.
    Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved.
    This arrange is synchronous s informative impolite festivity to pity. I appreciated what you ok extremely here.


    Selenium interview questions and answers
    Selenium Online training
    Selenium training in Pune
    selenium training in USA
    selenium training in chennai

    ReplyDelete
  26. Nice post. The blog is very useful to write and also easy to understand. Thank you for sharing the information.
    moviebox application
    show box

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Thank you for sharing such a nice post!

    Looking for Best Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT Software Course in Bangalore , India. Also, it provides placement assistance service in Bangalore for IT.

    ReplyDelete
  29. Thanks for sharing this blog. This very important and informative blog.Become a Trainer

    ReplyDelete
  30. Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind.Student Reviews

    ReplyDelete
  31. Thanks for sharing this blog. This very important and informative blog. content










    ReplyDelete
  32. Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

    Learn SAP from the Industry Experts we bridge the gap between the need of the industry. eTechno Soft Solutions provide the Best IT Training in Bangalore .

    ReplyDelete
  33. Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge. Real Time Experts training center bangalore

    ReplyDelete
  34. Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge.student review for Realtime Experts marathahalli bangalore

    ReplyDelete
  35. Good Post!, it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
    AngularJS Online Training

    ReplyDelete
  36. Thanks for giving a wonderful article. If you want to promote your blog page or your product or your business then go for bulk sms service Chennai, they provide the best bulk sms service.

    bulk sms in bangalore | bulk sms explicit Bangalore | promotional sms provider | bulk sms reseller mysuru | SMS API | bulk sms gateway | sms implicit

    ReplyDelete