-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UserNotifications Framework for iOS 10+ #90
Conversation
On my local machine the tests do run. Does anybody has an idea why the checks fail? |
@delba what's going on? |
Any chance this is going to be merged? |
Source/Permission.swift
Outdated
@@ -98,31 +116,22 @@ open class Permission: NSObject { | |||
return Permission(type: .notifications(settings)) | |||
}() | |||
|
|||
/// Variable used to retain the notifications permission. | |||
fileprivate static var _notifications: Permission? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is used to retain the permission as stated in the comment above.
Source/Permission.swift
Outdated
/// The permission to send notifications. | ||
open static func notifications(types: UIUserNotificationType, categories: Set<UIUserNotificationCategory>?) -> Permission { | ||
let settings = UIUserNotificationSettings(types: types, categories: categories) | ||
let permission = Permission(type: .notifications(settings)) | ||
_notifications = permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_notifications
is used to retain the permission
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
} | ||
|
||
/// The permission to send notifications. | ||
open static func notifications(types: UIUserNotificationType) -> Permission { | ||
let settings = UIUserNotificationSettings(types: types, categories: nil) | ||
let permission = Permission(type: .notifications(settings)) | ||
_notifications = permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
} | ||
|
||
/// The permission to send notifications. | ||
open static func notifications(categories: Set<UIUserNotificationCategory>?) -> Permission { | ||
let settings = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: categories) | ||
let permission = Permission(type: .notifications(settings)) | ||
_notifications = permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Source/Permission.swift
Outdated
/// The permission to send notifications. | ||
@available(iOS 10.0, *) | ||
open static func userNotifications(options: UNAuthorizationOptions) -> Permission { | ||
return Permission(type: .userNotifications(options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to retain the permission with a private var like in the case of notifications
(e.g: _userNotifications
)
Source/PermissionType.swift
Outdated
@@ -21,6 +21,9 @@ | |||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
// SOFTWARE. | |||
// | |||
#if PERMISSION_NOTIFICATIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be PERMISSION_USERNOTIFICATIONS
Permission.podspec
Outdated
@@ -1,6 +1,6 @@ | |||
Pod::Spec.new do |s| | |||
s.name = "Permission" | |||
s.version = "2.0.3" | |||
s.version = "2.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to change it just before pushing it (and it's dependent on the git tag)
Permission.podspec
Outdated
@@ -64,6 +64,11 @@ Pod::Spec.new do |s| | |||
no.pod_target_xcconfig = { "SWIFT_ACTIVE_COMPILATION_CONDITIONS" => "PERMISSION_NOTIFICATIONS" } | |||
end | |||
|
|||
s.subspec 'UserNotifications' do |no| | |||
no.dependency 'Permission/Core' | |||
no.pod_target_xcconfig = { "SWIFT_ACTIVE_COMPILATION_CONDITIONS" => "PERMISSION_USERNOTIFICATIONS" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename PERMISSION_USERNOTIFICATIONS
to PERMISSION_USER_NOTIFICATIONS
for the sake of consistency please?
import UserNotifications | ||
|
||
internal extension Permission { | ||
var statusUserNotifications: PermissionStatus { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we keep the structure of the Motion
permission (that also uses "synchronous" calls) please ?
Hi @mrgrauel, thanks a lot for the PR! There are a just few changes to do before merging though. |
Good Morning @delba, is it now as you want it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Source/Permission.swift
Outdated
/// The permission to send notifications. | ||
open static func notifications(types: UIUserNotificationType, categories: Set<UIUserNotificationCategory>?) -> Permission { | ||
let settings = UIUserNotificationSettings(types: types, categories: categories) | ||
let permission = Permission(type: .notifications(settings)) | ||
_notifications = permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
* for example if you add Permissions in an already existing application * user would be stuck in a deadlock
@delba I changed everything. I dunno why it still says that a change request is open. |
@delba Hello?!?!?! |
@delba Has this issue been fixed? I still get these xcode 10 deprecation warnings. It wont compile with target iOS 10 |
^^ @delba Sorry about that, I thought I was on my fork. I know it doesn't actually merge the PR, but why does GitHub even give me the option. :\ |
@delba Please merge this PR |
Losing hope :/ |
Hey everybody, I've given up on waiting for @delba to answer and merge our PRs. Instead I've integrated this PR into my fork (which I created for #94). I've also created my own CocoaPods entry so we can continue using this framework and merging our improvements together. Feel free to star and send your PRs to my fork in the future. I will try to review them from time to time: To switch to my fork in your project simply replace |
@Dschee nice move 👍 |
Hi @mrgrauel, the project has been updated to the latest Swift version and now uses |
I added a permission for the new notification framework UserNotifications in iOS 10 to request permission with the new api.
UserNotification
PERMISSION_USERNOTIFICATIONS
userNotifications
_notification
cause it's never readrequestedNotifications
default cause it returns the same informationI tried to keep it in the structure you designed the framework.