2012-09-01 10 views
5

मैं एक बॉक्स 2 डी गेम विकसित कर रहा हूं। खेल में मैं पुशवॉश पुश अधिसूचना का उपयोग कर रहा हूं। यह ठीक काम कर रहा है (पुशवॉश सर्वर से पुश अधिसूचना प्राप्त करना) लेकिन जब मैं पुश अधिसूचना टैब करता हूं तो मेरा गेम क्रैश हो जाता है। AppDelegate में इसटैब पुश अधिसूचना cocos2d खेल दुर्घटनाग्रस्त है

अलावे Appdelegate.h तरह लागू:

@interface AppDelegate:NSObject<UIApplicationDelegate,AdColonyDelegate,PushNotificationDelegate,UIAlertViewDelegate>{ 
     UIWindow   *window; 
     RootViewController *viewController; 
     PushNotificationManager *pushManager; 
    } 
    @property (nonatomic, retain) PushNotificationManager *pushManager; 
    @property (nonatomic, retain) UIWindow *window; 
    @property (nonatomic, retain) RootViewController *viewController; 
    @end 



    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
     // Init the window 
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 


    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationType)(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; 

    //initialize push manager instance 
    pushManager = [[PushNotificationManager alloc] initWithApplicationCode:@"PushWoosh App_ID" appName:@"App_Name" ]; 
    pushManager.delegate = self; 
    [pushManager handlePushReceived:launchOptions]; 
    /*pushManager = [[PushNotificationManager alloc] initWithApplicationCode:@"FA7CF-665BF" navController:self.viewController appName:@"Cricket" ]; 
    pushManager.delegate = self; 
    [pushManager handlePushReceived:launchOptions];*/ 

    // Try to use CADisplayLink director 
    // if it fails (SDK < 3.1) use the default director 
    if(! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink]) 
     [CCDirector setDirectorType:kCCDirectorTypeDefault]; 


    CCDirector *director = [CCDirector sharedDirector]; 

    // Init the View Controller 
    viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; 
    viewController.wantsFullScreenLayout = YES; 

    // 
    // Create the EAGLView manually 
    // 1. Create a RGB565 format. Alternative: RGBA8 
    // 2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition 
    // 
    // 
    EAGLView *glView = [EAGLView viewWithFrame:[window bounds] 
            pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8 
            depthFormat:0      // GL_DEPTH_COMPONENT16_OES 
         ]; 

    // attach the openglView to the director 
    [director setOpenGLView:glView]; 

    // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices 
    if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) 
    { 
     if(! [director enableRetinaDisplay:YES]) 
      CCLOG(@"Retina Display Not supported"); 
    } 

    // 
    // VERY IMPORTANT: 
    // If the rotation is going to be controlled by a UIViewController 
    // then the device orientation should be "Portrait". 
    // 
    // IMPORTANT: 
    // By default, this template only supports Landscape orientations. 
    // Edit the RootViewController.m file to edit the supported orientations. 
    // 
#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
    [director setDeviceOrientation:kCCDeviceOrientationPortrait]; 
#else 
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeRight]; 
#endif 

    [director setAnimationInterval:1.0/60]; 
    [director setDisplayFPS:YES]; 


    // make the OpenGLView a child of the view controller 
    [viewController setView:glView]; 

    // make the View Controller a child of the main window 
    [window addSubview: viewController.view]; 

    [window makeKeyAndVisible]; 

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images 
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565 
    // You can change anytime. 
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; 


    // Removes the startup flicker 
    [self removeStartupFlicker];  


    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    if(![defaults integerForKey:@"First"]) { 

     [[CCDirector sharedDirector]runWithScene:[MainMenu scene]]; 
    } 
    else { 

     [[CCDirector sharedDirector]runWithScene:[PlayAsGuestScene scene]]; 
    } 


    return YES; 
} 

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ 

     [pushManager handlePushReceived:userInfo]; 
} 
    - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{ 
    [pushManager handlePushRegistration:deviceToken]; 

    //you might want to send it to your backend if you use remote integration 
    NSString *token = [pushManager getPushToken]; 
} 

कंसोल में मैं इस त्रुटि हो रही है: * समाप्त एप्लिकेशन न आया हुआ अपवाद 'NSInvalidArgumentException', कारण की वजह से: '- [AppDelegate ऑन पुश स्वीकृत:]: अज्ञात चयनकर्ता उदाहरण 0xf50d290 '

ऐसा क्यों होता है?

+1

ओह, आम, क्रैश होने पर हमें और कोड दें? क्या आपने अपवाद ब्रेकपॉइंट सेट अप करने का प्रयास किया था? हमें और जानकारी दें ... – mientus

उत्तर

1

अंततः मुझे यह मिला। मैं

-(void)applicationDidFinishLaunching:(UIApplication*)application{ 

    pushManager = [[PushNotificationManager alloc] initWithApplicationCode:@"PushWoosh App_ID" appName:@"App_Name" ]; 
    pushManager.delegate = self; 

} 

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ 

     //write own code 
} 

मेरा ऐप क्रैश के बिना काम कर रहा है।

संबंधित मुद्दे