Commit 127446e

mo khan <mo@mokhan.ca>
2013-03-31 01:03:42
yes you can get the twitter username and uid from the social api
1 parent 974e1b9
app/controllers/location_controller.rb
@@ -23,5 +23,22 @@ class LocationController < UIViewController
       @text_field.enabled = false
       p @text_field.text
     end
+
+    access_twitter
     end
+
+  def access_twitter
+    @account_repository = ACAccountStore.alloc.init
+    @twitter_account_type = @account_repository.accountTypeWithAccountTypeIdentifier ACAccountTypeIdentifierTwitter
+    @account_repository.requestAccessToAccountsWithType @twitter_account_type, options:nil, completion: lambda { |granted, error|
+      if granted
+        @accounts = @account_repository.accountsWithAccountType @twitter_account_type
+        p "ID: #{@accounts.first.accountProperties['user_id']} #{@accounts.first.username}"
+
+        puts "GRANTED ACCESS"
+      else
+        puts "NOT GRANTED"
+      end
+    }
+  end
 end
app/app_delegate.rb
@@ -1,8 +1,8 @@
 class AppDelegate
   def application(application, didFinishLaunchingWithOptions:launchOptions)
     @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
-    @search_controller = LocationController.alloc.initWithNibName(nil, bundle:nil)
-    @navigation_controller = UINavigationController.alloc.initWithRootViewController(@search_controller)
+    @location_controller = LocationController.alloc.initWithNibName(nil, bundle:nil)
+    @navigation_controller = UINavigationController.alloc.initWithRootViewController(@location_controller)
 
     @window.rootViewController = @navigation_controller
     @window.makeKeyAndVisible
Rakefile
@@ -7,4 +7,5 @@ Bundler.require
 Motion::Project::App.setup do |app|
   # Use `rake config' to see complete project settings.
   app.name = 'phoking'
+  app.frameworks += ['Social', 'Twitter']
 end