2015-01-15 120 views
0

我正在嘗試爲iOS創建一個cordova應用程序。我們也用於android的同一個應用程序。我只是試圖添加iOS插件並啓動應用程序。我在CDVDevice.h中添加了以下代碼。帶插件的iOS科爾多瓦應用程序

http://developmobilesoftware.blogspot.in/2013/12/the-unique-identifier-in-ios-app-udid.html

我得到例外,我的跟蹤是爲下:

+[CDVDevice uniqueIDForDevice] : unrecognized selector sent to class 0xf30c4 
** WebKit discarded an uncaught exception in the webView: decidePolicyForNavigationAction:request:frame:decisionListener:delegate"<NSInvalidArgumentException> +[CDVDevice uniqueIDForDevice]: unrecognized selector sent to class 0xf30c4 

請幫助我的新的iOS編程。

謝謝!

回答

0

首先,編輯CDVDevice是不是一個好主意

但是你可以做兩個不同的東西,以修正你的代碼:

變化[devProps setObject:[[self class] uniqueIDForDevice] forKey:@"uniqueid"];

[devProps setObject:[self uniqueIDForDevice] forKey:@"uniqueid"];

或改變-(NSString*)uniqueIDForDevice

+(NSString*)uniqueIDForDevice

說明,類方法+開始,實例方法開始-,你聲明的實例方法,但你怎麼稱呼它像一個類的方法,這樣你就可以改變類方法實例方法改變-+或保留它作爲實例方法,只是用self代替[self class]

稱其爲實例方法不管怎麼說,正如我之前說的,而不是編輯工作的設備插件,你可以用我的標識符廠商插件

https://github.com/jcesarmobile/IDFVPlugin

window.IDFVPlugin.getIdentifier(function(identifier){ alert(identifier); },function(error){ alert(error); }); 
+0

謝謝!我很好奇,想知道我的代碼有什麼問題.. [devProps setObject:[[self class] uniqueIDForDevice] forKey:@「uniqueid」]; 這是我試圖訪問該方法,並將其添加到device.js – Programmer

+0

然後張貼您正在使用的整個代碼,而不是鏈接到博客文章 – jcesarmobile

+0

在 - (NSDictionary *)CDVDevice.h的deviceProperties添加了一個行 [devProps setObject:[[self class] uniqueIDForDevice] forKey:@「uniqueid」]; 和device.js me.uniqueid = info.uniqueid; – Programmer

相關問題