2011-07-29 5 views
6

ここで問題が発生しています:アプリをバックグラウンドで実行しないように設定していますが、githubで見つかったlocalNotificationプラグインを使用してdailyIntervalローカル通知:https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/LocalNotificationPhoneGap/iOS LocalNotification Appが「表示」をタップしたときにクラッシュする

通知がポップアップするとアプリがクラッシュし、「表示」をタップします。何かが送信されているように見え、何が起こっているのかわかりません。私はObjective Cが私にとって外国語なので何が起こっているのか分からない。誰でもアイデアはありますか?

--------- Console Log ---------- 

7/29/11午前11時05分48秒AM午後断言[12004] - [UIConcreteLocalNotification absoluteString]:未認識セレクタ0x5c22240

7/29/11 11:05:48 AM Afternoon Affirmations[12004] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIConcreteLocalNotification absoluteString]: unrecognized selector sent to instance 0x5c22240' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x017f65a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x0194a313 objc_exception_throw + 44 
    2 CoreFoundation      0x017f80bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x01767966 ___forwarding___ + 966 
    4 CoreFoundation      0x01767522 _CF_forwarding_prep_0 + 50 
    5 Afternoon Affirmations    0x00002f21 -[AppDelegate application:didFinishLaunchingWithOptions:] + 257 
    6 UIKit        0x002f7c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 
    7 UIKit        0x002f9d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439 
    8 UIKit        0x00304617 -[UIApplication handleEvent:withNewEvent:] + 1533 
    9 UIKit        0x002fcabf -[UIApplication sendEvent:] + 71 
    10 UIKit        0x00301f2e _UIApplicationHandleEvent + 7576 
    11 GraphicsServices     0x020e5992 PurpleEventCallback + 1550 
    12 CoreFoundation      0x017d7944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    13 CoreFoundation      0x01737cf7 __CFRunLoopDoSource1 + 215 
    14 CoreFoundation      0x01734f83 __CFRunLoopRun + 979 
    15 CoreFoundation      0x01734840 CFRunLoopRunSpecific + 208 
    16 CoreFoundation      0x01734761 CFRunLoopRunInMode + 97 
    17 UIKit        0x002f97d2 -[UIApplication _run] + 623 
    18 UIKit        0x00305c93 UIApplicationMain + 1160 
    19 Afternoon Affirmations    0x00002d7f main + 127 
    20 Afternoon Affirmations    0x00002cf5 start + 53 
) 

7/29/11 11:05:48 AM UIKitApplication:com.InTheRooms.AfternoonAffirmations[0x9a52][12004] terminate called after throwing an instance of 'NSException' 
+0

1を説明するブログ記事

は、私は同じ問題を抱えています。あなたは解決策を見つけましたか? – Samuel

+0

アプリをバックグラウンドで実行するように設定するとクラッシュすることはありません(アプリケーションはバックグラウンドで実行されない= NO)。 -/ – Samuel

+0

@SamuelMichelotこのプラグインがまったく動作しない(クラッシュしたり、通知がない)ことに問題があります。このプラグインが動作しなくなった場合、このプロパティでクラッシュします。多分、私はそれを正しく設定しています。私を助けてくれますか? – xdumaine

答えて

3

をインスタンスにOKを送信し、私はそれがだ、問題を発見しましたAppDelegate.mファイル、より正確にはmethod:didFinishLaunchingWithOptionsに記述します。この方法は、最初のオプションパラメータがURLである(ただし、我々はローカル通知を経由してアプリを起動したときにそれがないことを前提として迅速かつ汚い修正は、コードコメントをすることです:。少しでも良い解決策が何かある

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    //commented out because it makes the app crash at startup with local notification... 
    /*NSArray *keyArray = [launchOptions allKeys]; 
    if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil) 
    { 
     NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]]; 
     self.invokeString = [url absoluteString]; 
     NSLog(@"Mosa_fr_en-busi launchOptions = %@",url); 
    }*/ 

    return [super application:application didFinishLaunchingWithOptions:launchOptions]; 
} 
0

を私は地元の通知と同様の問題があった

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    NSArray *keyArray = [launchOptions allKeys]; 
    if ([keyArray count] > 0) { 
     id option = [launchOptions objectForKey:[keyArray objectAtIndex:0]]; 
     if ([option isKindOfClass:[NSURL class]]) { 
      NSURL *url = (NSURL *)option; 
      self.invokeString = [url absoluteString]; 
      NSLog(@"ContactInbox launchOptions = %@",url); 
     } 
    } 

    return [super application:application didFinishLaunchingWithOptions:launchOptions]; 
} 

誰かがPho​​neGapのは、URLのために、それは実際のキーで[keyArray objectAtIndex:0]部品を交換する方が良いでしょう持っていることを期待キーを知っている場合は

0

私が選んだ解決策がある:このように。少しばかり家賃(かなり似ているが)。私は、ローカル通知の起動オプション(UIApplicationLaunchOptionsLocalNotificationKey)のチェックを使用しています。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 

    if(localNotif) 
    { 
     // Do whatever you need to do with that local notitication 
    } 
    else 
    { 
     NSArray *keyArray = [launchOptions allKeys]; 
     if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil) 
     { 
      NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]]; 
      self.invokeString = [url absoluteString]; 
     } 
    } 
    return [super application:application didFinishLaunchingWithOptions:launchOptions]; 
} 

アップルドキュメント::ここで

が短い例で、誰もが興味を持っている場合、私はlocalNotificationプラグインを再書かれてきました http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html

関連する問題