Comments (8)
Would really like to see Promise functionality for registerForPushNotifications
. Anyone? 🙏🏼
from react-native-onesignal.
@dwilt you can use AppState and call OneSignal.checkPermissions
again when app "active" state to get user's response
from react-native-onesignal.
More than happy to accept PR for this.
from react-native-onesignal.
@jkasten2 can you help on this?
from react-native-onesignal.
OneSignal SDK does not allow me to do that. Also, For my best understanding, there is no way to actually know if the user accepted the push notifications dialog or not. But, it's possible to check if the notifications are enabled at a later time.
Current work on progress:
+ (BOOL)isPushNotificationsEnabled {
BOOL isEnabled = NO;
if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]){
UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (!notificationSettings || (notificationSettings.types == UIUserNotificationTypeNone)) {
isEnabled = NO;
} else {
isEnabled = YES;
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert) {
isEnabled = YES;
} else{
isEnabled = NO;
}
}
return isEnabled;
}
When you'll ask for OneSignal.isPushNotificationsEnabled
it should give you an answer if notifications are enabled or not. I'm still working on it so i'm not sure it's the proper way to do that.
from react-native-onesignal.
Well, I took some inspiration from PushNotificationsIOS
and now 0b8e7e0 fixes that. You can't return a promise right now on the request permissions method, but you can check what permissions your device have, with a callback.
from react-native-onesignal.
Thanks!
from react-native-onesignal.
@avishayil so there is no way to know when the user has chosen Allow
or Don't Allow
?
I know we can check the current permissions with checkPermissions
but how would we know when to check if we can't tell when they've responded to the modal?
Aren't you guys just using the native code that PushNotificationIOS is doing? Can't you use what they are? Should I just call await PushNotificationIOS.requestPermissions()
myself?
Also, it would be helpful to update checkPermissions
to use a promise syntax instead of a callback. Right now we're promisifying
it manually:
export function checkPermissions() {
return new Promise(resolve => {
OneSignal.checkPermissions(resolve);
});
}
from react-native-onesignal.
Related Issues (20)
- [Bug]: Permission Not Granted (Android) HOT 5
- [Bug]: Push Notifications Not Reaching TestFlight Builds
- [Bug]: Crash "RuntimeException: Could not invoke OneSignal.hasNotificationPermission" HOT 2
- [Bug]: OneSignal.login() doesn't set the externalId in react native HOT 2
- [Bug]: Push Notification with status FAILED on iOS HOT 2
- Can't find any documentation on how to handle the actions buttons in my notification HOT 3
- ⚠️ 5.0.0 to 5.1.0 Deprecated - These version may be blocked or rate limited. Please update to 5.1.1 or newer ⚠️ HOT 1
- [Bug]: Android release APK crashing HOT 1
- [Bug]: External Id is not getting set HOT 1
- [Bug]: Cycle inside SampleProject; building could produce unreliable results HOT 3
- [Bug]: addTag could not be invoked HOT 3
- [Bug]: react native App Crashes in Android device Only, works on emulator HOT 1
- [Bug]: canRequestPermission is not working as expected HOT 3
- [Bug]: Missing API declaration HOT 3
- [Bug]: Can not build at AppCenter HOT 1
- [question]: Issue with Push Notifications in App Store Builds HOT 1
- iOS: Badge not showing HOT 2
- [Bug]: In v5, the Subscription Status does not change to 'Subscribed'. HOT 9
- [Bug]: permissionChange listener is not giving the correct hasPermission value until background/foreground HOT 3
- [question]: getIdAsync is returning null with latest SDK HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-onesignal.