LoginSignup
1
1

More than 5 years have passed since last update.

RubyMotion で Google Analytics SDK for iOS v2 (Beta)

Last updated at Posted at 2013-01-02

半分は RubyMotion ではじめるGoogle Analytics for iOS の内容で良いが、差分。

使用するフレームワークが変更されている

Rakefile に記述するフレームワークの指定が変更されている。

  app.frameworks << "CFNetwork"

の箇所を

  app.frameworks << "CoreData"
  app.frameworks << "SystemConfiguration"

にする。

初期化

app_delegate.rb などの application(application, didFinishLaunchingWithOptions:launchOptions) で次のように初期化。

    GAI.sharedInstance.tap do |gai|
      gai.trackUncaughtExceptions = true
      gai.dispatchInterval = 20
      gai.debug = true
      gai.trackerWithTrackingId("UA-XXXXXXXX-X")
    end

あとは、UIViewController を継承しているクラスなどを GAITrackedViewController を継承するように置き換えて、trackedViewName を設定してあげる。下記は UIViewController の代わりとなる MyViewController の例で、trackedViewName を自動的にその ViewController のクラス名になるようにしている。

class MyViewController < GAITrackedViewController
  def viewDidLoad
    super
    self.trackedViewName = self.class.name
  end
end

参考ドキュメント : https://developers.google.com/analytics/devguides/collection/ios/v2/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1