2016-11-17 58 views
1

我的問題是如何在iOS中真正實現和使用cocoapod模塊,我想在我的nativescript應用程序中使用谷歌轉換跟蹤窗口,但我不能讓它工作。我可以安裝吊艙,但是當我嘗試使用它時,我不可能。Nativescript - cocoapod /谷歌轉換跟蹤

是否有任何良好的指導如何使用nativescript實現cocoapod模塊?

這是代碼我嘗試在我的app.module.ts

class MyDelegate extends UIResponder implements UIApplicationDelegate { 
public static ObjCProtocols = [UIApplicationDelegate]; 

applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary): boolean { 
    console.log("applicationWillFinishLaunchingWithOptions"); 

// Google iOS in-app conversion tracking snippet 
// Add this code to the event you'd like to track in your [ACTAutomatedUsageTracker enableAutomatedUsageReportingWithConversionID:@"12345678"]; 
    //ACTConversionReporter.reportWithConversionIDLabelValueIsRepeatable("12345678", "AASsoighsingaxx", "0.00", true); 
[ACTConversionReporter reportWithConversionID:@"12345678" label:@"AASsoighsingaxx" value:@"0.00" isRepeatable:YES]; 

    return true; 
} 

applicationDidBecomeActive(application: UIApplication): void { 
    console.log("applicationDidBecomeActive: " + application) 
    } 
} 
application.ios.delegate = MyDelegate; 

我是支持聲明任何進口跑?如果是這樣,怎麼樣? 我使用https://docs.nativescript.org/plugins/cocoapods中解釋的方法安裝吊艙。

回答

0

要使用cocoapod,您必須創建一個通過Podfile導入cocoapod的NativeScript插件。例如,請查看the Podfile in my nativescript-midi plugin

從Cocoapod的Objective-C類將作爲全局對象,一旦你用下面的命令來安裝插件:

tns plugin install ../path/to/plugin 

由於Objective-C類在全球範圍內曝光,你利用它們不導入他們。查看the IosMidiDeviceManager class in my plugin就可以看出這個例子。在文件的頂部,我添加了一條評論,指示JSHint不要在沒有聲明的情況下使用PGMidi,但除此之外,我只是直接實例化並使用它。