[英]How to control when Netmera ios sdk will prompt Push notifications permission?
我在我的應用程序中使用Netmera SDK。 在應用啟動后立即提示用戶允許“推送”通知。 在用戶登錄我的應用程序后如何控制該行為並詢問用戶的許可? 添加或刪除[Netmera setApiKey:kNetmeraAPIKey];
線沒有效果。 即使刪除對<Netmera/Netmera.h>
所有依賴關系也無效。 看起來Netmera SDK會以某種方式注入調用registerUserNotificationSettings:
方法...我不知道。 有什么可以解決的辦法嗎?
當前尚沒有簡便的方法可以做到這一點。 在下一個主要版本中,將有一個更好的權限管理流程:)
但是,現在您可以執行以下操作:
將類別聲明添加到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)];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.