【发布时间】:2017-07-06 16:52:23
【问题描述】:
如何检查用户在代号one或native的ios中是否拒绝或接受了推送通知权限消息?
【问题讨论】:
-
请不要全大写我们。
-
如果我没有问你,我会失职但是:你有没有试过先在谷歌上写同样的问题?
-
是的,我找到了很多,但在 codenameone 中似乎没有任何关系
标签: codenameone
如何检查用户在代号one或native的ios中是否拒绝或接受了推送通知权限消息?
【问题讨论】:
标签: codenameone
Android 和 iOS 都有 API 来检测是否启用了推送: Push Notification ON or OFF Checking in iOS
Android 4.1: How to check notifications are disabled for the application?
由于这些是最近才添加的,而且我们没有得到足够的需求,因此我们目前不支持它们。您可能可以使用本机接口调用它们或提交带有集成的拉取请求。通常你会在推送工作时收到一个推送注册的回调,如果没有,你会得到一个错误或什么都没有。
【讨论】:
我找到了一个实现 IOS 10 原生功能的解决方案
这些方法在 Objective-c 和 codenameone 代码中完美运行
//------------------------------------------------------------------------------
//This method is use to check if the user enable or disable push notification
//------------------------------------------------------------------------------
-(BOOL)isPushNotificationIsEnable{
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {
NSLog(@"isPushNotificationIsEnable()->YES");
return YES;
} else {
NSLog(@"isPushNotificationIsEnable()->NO");
return NO;
}
}
//------------------------------------------------------------------------------
//This method is use to launch the Notification screen of your app
//------------------------------------------------------------------------------
Display.getInstance().execute("App-Prefs:root=NOTIFICATIONS_ID&path=your package name app", new ActionListener() {
String methodName = "startLocationSetting";
@Override
public void actionPerformed(ActionEvent evt) {
boolean status = Utils.isPushNotificationEnable();
}
});
//------------------------------------------------------------------------------
【讨论】: