Integrating Twitter to iOS application


#1

I am having a bad luck trying to integrate twitter to my ARC enabled iPhone application. Can someone tell me if there’s a Twitter ARC compatible API available (and also an example code/tutorial) or anyway i could integrate twitter to my ARC enabled application?


#2

Twitter.framework works fine in ARC-enabled projects. You do not need a separate ARC version.

What errors are you seeing? I’ll see if I can help you with the issue.


#3

Twitter.framework supports ARC, and it works only for iOS 5 and above. But i have to create an application that supports iOS 4 and above. In that case, Twitter.framework doesn’t support iOS 4. So what should i do ?

note: the project is created using ARC, and should support both iOS 4 and 5


#4

OK, the question is really if there is a Twitter framework for iOS4. There is not, but we are planning to release a library that assists with backwards compatibility for projects that require 4.0 support.

As far as ARC is concerned, it’s performed by the compiler, not the OS. You can use it in an application that targets iOS4.0, with the exception of the “weak” modifier.

From the documentation (1):

“ARC is supported in Xcode 4.2 for Mac OS X v10.6 and v10.7 (64-bit applications) and for iOS 4 and iOS 5. Weak references are not supported in Mac OS X v10.6 and iOS 4. There is no ARC support in Xcode 4.1 and earlier.”

(1): http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html#//apple_ref/doc/uid/TP40011226


#5

As a workaround i’ll add both MGTwitterEngine to deal with iOS4 devices, and twitter.framework for iOS5 devices. Hope this will not be a problem


#6

That sounds like a great workaround for now. If you run into any hurdles, please let us know.


#7

Yes sure, i will be testing the app on device tomorrow. I’ll keep you updated. Thank you


#8

Once i added the files for the MGTwitterEngine, and compiled i got 9 Warnings. These is the screenshot of the warnings i got. http://imageshack.us/photo/my-images/214/screenshot20120114at233.png/

What could i do to prevent this ? (This is for iOS 4 Twitter integration)


#9

My recommendation would be to use the compiler flags “-w -Xanalyzer -analyzer-disable-checker” for 3rd party libraries. This silences compile warnings as well as warnings from the static analyzer.

You can set these in your target’s “Build Phases”, under “Compile Sources”. Double-click the file whose warnings you wish to silence, enter the the flags above and press enter.


#10

i have added all haeders files which i need for twitter integration provide me way for integrate twitter for my app


#11

Look at the example implementation provided at https://github.com/rsieiro/RSOAuthEngine . It has ARC support too.


#12

If you need to include non-arc code in your arc project, set the “-fno-objc-arc” compiler flag for each respective .m under “Build Phases”. The project should then compile properly.


#13

I too would like to use MGTwitterEngine for iOS 4 support in addition to the Twitter Framework for iOS 5. However, I’m having an issue.

After some research, I’ve found that we can’t support Twitter OAuth via the iOS app and the web under our current configuration. The web OAuth flow requires that we set the Callback URL in our application configuration on Twitter.

For this flow to work properly, the app’s OAuth flow needs to include the “oauth_callback” parameter in the request token call (the first call that gets made). That value can either be set to a “custom URL” that the app would understand to open or “oob” (out of band, I’m not sure that this is still supported by Twitter). Omitting the callback URL from the Twitter application configuration causes Twitter to treat all requests like they are coming from a non-browser client.

The problem is I cannot find any way to pass the oauth_callback parameter using the MGTwitterEngine in the Twitter-OAuth-iPhone.

Also, theSeanCook: any idea how long until the library you mentioned for backwards support is available? :slight_smile:

Thanks!


#14

Hi All,

I want to integrate twitter in my iPhone app so that I will be able to read the tweets.

Please suggest me. If some tutorial is available please let me know.

-SS


#15

As i have suggested in my previous post, try RSOAuthEngine. There is an example twitter integration which has used RSOAuthEngine, go through the code i think it will be easy to understand.

If your focusing on adding Twitter to only devices running iOS5, then consider the twitter.framework for iOS5. try (http://www.youtube.com/watch?v=0OwgbOvC2To)


#16

Dear Concerned,
I tried to integrate the bengottlieb / Twitter-OAuth-iPhone git.
It is working fine on all the devices except the iPhone 3GS devices.
iPhone 3GS iOS version 5.1
It always shows ‘The request token for this page is invalid.’ While on other devices iPhone 4 or above and iPad 1 or above it is working fine.
Please guide me with possible solution
Thanks & Regards,
Zahur


#17

My app works for iOS 4 devices. I have twitter integration for ios4 devices, but when someone with ios5 runs the application I want to use the Twitter framework. But the problem is that the app will stop running only if I include the framework. Do you have any ideas how should I include the twitter framework only for ios5 devices?


#18

Get the iOS version, if it’s iOS 5 use the Twitter framework (provided by Apple) or else (it is iOS4) so use your Twitter integration which you said is working. (This is a simple IF-ELSE statement)

ex:

If (iosVersion > 5) {
// Call Twitter framework provided by Apple
} else {
// Call any other framework that you are using to make it work for iOS4
}

The link http://stackoverflow.com/questions/3339722/check-iphone-ios-version/3339787#3339787 explains how to get the iOS version.


#19

Thank you for your replay.

I’ve tried to do it like this. My problem is that the app stops running on iOS 4 only if I include the Twitter framework. I’m not using the Twitter framework on iOS4 I’m only trying to include it in the project and use it if the iOS is greater than 5.

Is there any way of avoiding compiling the Twitter framework if the iOS is not 5?


#20

You can make the linking of the Twitter.framework and Account.framework optional which should allow your app to run on iOS4 as well as iOS5.

To do this: Under ‘Build Phases’ for your Target, expand the ‘Link Binary With Libraries’ section. For Twitter.framework and Accounts.framework, click on the text to the right that says ‘Required’ and change it to ‘Optional’.