Pregunta

I tried to remove nextpeer welcome notification at game start.

Here is my code in .h

@interface AppDelegate : NSObject <UIApplicationDelegate,NextpeerDelegate,NPTournamentDelegate,NPNotificationDelegate,..>

//in AppDelegate.m

- (void)initializeNextpeer
{
    NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:

                              // This game has no retina support - therefore we have to let the platform know
                              [NSNumber numberWithBool:TRUE], NextpeerSettingGameSupportsRetina,
                              // Support orientation change for the dashboard notifications
                              [NSNumber numberWithBool:FALSE], NextpeerSettingSupportsDashboardRotation,
                              // Support orientation change for the in game notifications
                              [NSNumber numberWithBool:TRUE], NextpeerSettingObserveNotificationOrientationChange,
                              //  Place the in game notifications on the bottom screen (so the current score will be visible)
                              [NSNumber numberWithInt:NPNotificationPosition_BOTTOM], NextpeerSettingNotificationPosition,
                              nil];



    [Nextpeer initializeWithProductKey:@"HERE ADDED GAME KEY" andSettings:settings andDelegates:
     [NPDelegatesContainer containerWithNextpeerDelegate:self notificationDelegate:[NPCocosNotifications sharedManager] tournamentDelegate:self]];


}
- (BOOL)nextpeerShouldShowWelcomeBanner {
    return NO; // Do not Show banner
}

Nextpeer working great. Only this function is not fired. What's wrong?

¿Fue útil?

Solución

nextpeerShouldShowWelcomeBanner is a method on the NPNotificationDelegate, not on NextpeerDelegate. In your code sample, the notification delegate is [NPCocosNotifications sharedManager]. So you should move the method to that object, or set a different notification delegate.

Otros consejos

EDIT: This no longer applies - it seems the current version of Nextpeer (1.7.4) doesn't support this.

You need to add the method to whichever class is implementing the NPNotificationDelegate not NextPeerDelegate.

But the trouble is, the default NPNotificationDelegate is NPCocosNotifications - which is a class inside the Nextpeer library. So when you update the library, you need to also remember to make the same edit again to the new version of NPCocosNotifications.

But there's a neater way to do this using a category, which means you don't need to make the edit again when you update.

1)

Create this file: NSObject+NPCocosNotification_NotShowWelcomeBanner.h

#import <Foundation/Foundation.h>
#import "NPCocosNotifications.h"

@interface NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

@end

Create this file: NSObject+NPCocosNotification_NotShowWelcomeBanner.m

#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

@implementation NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

- (BOOL)nextpeerShouldShowWelcomeBanner {
    return NO; // Do NOT show banner as the game starts up
}

@end

Drag those files into the project making sure the "Copy into destination group's folder (if needed)" is selected and "Add to target (your project's build target name)".

2) Add this line to your app delegate and any other files which reference NPCocosNotification

// This adds a method to prevent the welcome banner showing
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

The new method, to turn off the banner, will be added to NPCocosNotifications :)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top