2016-01-21 76 views
1

我在我的应用程序中使用Netmera SDK。它会在应用启动后立即提示用户对推送通知的许可。如何控制该行为并在他将在我的应用程序内登录后询问用户的许可? 添加或删除[Netmera setApiKey:kNetmeraAPIKey];行不起作用。 即使将所有依赖关系移除到<Netmera/Netmera.h>也没有效果。 看起来像Netmera SDK注入调用registerUserNotificationSettings:方法莫名其妙...我不知道。 有没有可以为此做的解决方法?如何控制Netmera ios sdk会提示推送通知权限?

回答

2

目前还没有一种简单的方法来做到这一点。在接下来的主要版本中,会有一个更好的许可管理流程:)

但是,现在你可以做到以下几点:

添加类声明NMPushManager + DisablePushOnLaunchHack.h文件:

#import <Netmera/Netmera.h> 

@interface NMPushManager (DisablePushOnLaunchHack) 

@end 

添加类别实施NMPushManager + DisablePushOnLaunchHack.m文件:

#import "NMPushManager+DisablePushOnLaunchHack.h" 

@implementation NMPushManager (DisablePushOnLaunchHack) 

+ (void)setEnabledUserNotificationTypesInternal:(UIUserNotificationType)type{ 
    // Do nothing. 
} 

@end 

最后,你应该添加#import "NMPushManager+DisablePushOnLaunchHack.h"到您的AppDelegate类,以防止Netmera自动注册到推送通知。

// You can set a different UIUserNotificationType combination 
[NMPushManager setEnabledUserNotificationTypes:(UIUserNotificationTypeAlert | 
               UIUserNotificationTypeSound | 
               UIUserNotificationTypeBadge)]; 

之后,你随时都可以使用下面的代码提示权限警告用户