When we first broke the news that iOS 5 would come with Twitter integration, I wasn’t thinking big enough. Based on the fairly vague (but credible) information I had, I figured it was mainly based around the Twitter Photos product which Twitter was rushing to get out in time. Turns out it goes much, much deeper. Apple has essentially baked a “Twitter Connect” into iOS 5. It’s something that all iOS apps will be able to easily use.

And they should. And they likely will.

It’s a massive win for Twitter. And a smart move by Apple . Social is not at their core, and they know it (*cough* Ping *cough*). So they partnered with a company that gets it. But what does it mean for the Twitter ecosystem? After days of dodging my questions, I finally got a chance to talk with Twitter’s head of platform, Ryan Sarver, about it this afternoon.

Apple gave a presentation at WWDC earlier today (which I wasn’t at — they don’t like my kind at such things) where they spelled out their vision for the Twitter integration with iOS. And this evening, Twitter is also holding an event at their headquarters in San Francisco to dive even deeper. Sarver expects it to be one of the largest events they’ve ever hosted.

“Overall the big thing for us is the combination of two big platforms,” Sarver told me. “And we’re complementary to each other. Twitter from day one has been a mobile-friendly company — that was a part of Jack’s [Dorsey] original vision. So to pair up with Apple on this is a great opportunity,” he continued, also pointing to the nice alignment of 200 million iOS devices with the 200 million Twitter accounts.

For developers, the value of this partnership breaks into two key things in Sarver’s mind. First, instant personalization. Any iOS app now has access to the Twitter connected identity and all its trappings and features. Second, there’s the distribution and user acquisition piece. Using the built-in Tweet Sheet feature in iOS 5 (essentially, a Tweet box that overlays on top of any app), any app can leverage Twitter’s network effects.

Sarver cited a recent stat the team behind Quora gave which said that every tweet going out from their service results in an average of 30 clicks back to Quora. Again, that’s on average for all links sent across the entire spectrum of Quora and Twitter users. “It’s an amazing amount of traffic,” Sarver noted, clearly suggesting that all iOS apps could potentially see the same type of thing.

But much of this was technically possible before. The difference now is that because it’s fully integrated into iOS 5, it will be more accessible to both developers and users. Sarver noted the simple hooks in place in the OS to add something like the Tweet Sheet. And for users, once they log in to the Twitter area in Settings in iOS, they’re basically all set for any app that uses the system.

Once you install an app with Twitter integration in iOS 5, you’ll see a single dialog box pop-up asking you if you’d like to connect the app to Twitter. This will look a lot like the pop-up that asks if you’d like an app to be able to use your location, Sarver said. Click, “OK” and you’re good to go. You’ll never be asked to enter a login/password or anything else. Nor will you see the pop-up box in that app ever again.

Imagine this in use for something like With, the latest app from Path. Because that app is built entirely around Twitter and iOS, this new integration is perfect for them. In the future, you’ll install the app, hit “OK” to enable Twitter integration, and you’re set.

If developers wish to go deeper, they can as well. iOS 5 has access to the entire Twitter API, Sarver noted. They essentially have a wrapper in place in the OS to allow developers to make calls to anything they want to use. And since it’s a wrapper (as opposed to iOS mirroring the API), whenever Twitter makes API additions or changes, iOS developers will be good to go as well.

So, now for the big question: where does this leave third-party client developers? After all, since the early days of the iPhone, they’ve been vital to the Twitter ecosystem.

There was a bit of a flare-up recently when Twitter revealed that they were moving developers from xAuth to OAuth usage in apps. The main driver behind this is that Twitter wants to have more control over the direct message feature of their service. This annoyed some developers because instead of a simple login/password sign-on, OAuth requires a user to go to Twitter’s site to authenticate an app.

But this is only for apps trying to access DMs. In other words, this mainly affects full clients. And the iOS/Twitter integration will be no different.

While Sarver declined to dive into xAuth/OAuth specifics in the iOS integration, he did say that there are multiple permission models. The one Apple is using for Twitter single sign-on in iOS 5 grants read/write access to Tweets and the ability to send DMs. But if an app wants to be able to read DMs, they will still need to authenticate on Twitter’s site with OAuth.

So yes, full Twitter clients made by third-parties are getting shafted a bit. Tweetbot, Seesmic, UberTwitter, Twitterrific, Echofon, etc.

But Sarver says this is not about screwing over those apps. “It honestly has nothing to do with making it harder for them,” he said. Instead, this authentication change is about protecting users. Sarver noted that very few apps should need access to DMs. And users probably don’t want apps like Angry Birds being able to read them when they don’t need to.

And of the 900,000 or so API tokens out there, and the 170,000 unique apps tweeting across the system, only hundreds of them are full clients that would want full DM support. “We want to work with them. But we need to think about protecting our users too,” Sarver said.

He did say that they’re thinking about a more elegant solution to the DM OAuth issue (which goes into effect at the end of this month). And if they can come up with something, they’d certainly be open to asking Apple to include it in a future version of iOS as well, Sarver said.

“We wanted to give guidance for the client-makers. We still allow them. They can still build clients. It’s not an area we’re turning off,” Sarver continued. At the same time, “if I were building a client, I would do it without DM access. But that’s just me,” he said.

At least that’s honest. And it reiterates his previous statements on Twitter’s increasingly complex (and conflicted) relationship with third-party client makers.

To lighten the mood, I asked about Twitter’s reliability. What if Twitter goes down, will iOS pop up a little Fail Whale notification, I wondered? Sarver laughed. “As always, developers need to code defensively,” he said. But he noted that a bigger problem may be the loss of cellular connectivity. And he said that Twitter’s reliability has been very stable lately, especially the API (which is true).

In terms of working more closely with other mobile players, Sarver said that Twitter brings a great and important social layer to mobile and they’d love to see it more places. But for now, this core iOS integration is going to be the huge emphasis for them.

And it goes both ways.

“I think this integration has the potential to be the second biggest referral for app growth behind the App Store,” Sarver said. “I think the main point in my mind is that if you’re making an app for iOS and you’re not thinking about Twitter, you’re really missing an opportunity.”

There is no question in my mind that this integration is going to be huge for all parties involved. Well, except other iOS Twitter clients who, if not hurt by the DM issue, will be hurt by the fact that Twitter’s own app is promoted in the Twitter settings area of iOS.

More specifically, it seems impossible to overstate just how big of a win this is for Twitter. This is a deal that Facebook seemed destined for and would have further cemented their hold on social identity. Now their single sign-on solution looks very weak, by comparison. Twitter must be laughing at it, backed by 200 million devices, each with access to 400,000+ apps — many of which should soon feature Twitter fabric woven deep.

Here, at least, light blue beats dark blue.