-
Notifications
You must be signed in to change notification settings - Fork 506
onAuthChange always return Unauthorized for Notifications #125
Comments
Could you try it with a real device ? |
Hi!... Yes tested on real device, iPhone 6 iOS 9.1, same result. |
Hi ed, Some additional questions:
|
@ed-mejia You should be using the |
😓 yep, didn't even realize you were calling the request method directly... Still, I think there's a problem with the request methods (when the intent is to call them directly): |
Hi @nickoneill , I don't want to display the default UI, I want to use my own, so that's the reason to use @bre7 That's weird despite the fact that initially returned |
|
@bre7 I don't understand, onAuthChange is being called, and even I tap OK to allow permission the closure is called indicating that I did't granted. |
Yeah, ignore that last comment. Call |
singlePscope.onAuthChange = { (finished, results) in
print("got results \(results)")
print("statusNotifications \(self.singlePscope.statusNotifications())")
} Console:
Should I use this hack? |
Got it. Cloudkit's getResultsForConfig + owaves fix fixed it. Check the new branch PENDING: |
@bre7 Hey I tested the new branch and seems to be working correctly now for direct requests. Im using cocoapods, this fix is going to be merge into master? Im kind of lost how to update my project to include any update since the last release 1.0.1 is 26 commits ahead to master |
Once we get this sorted out, nick will probably push a new version. As I said before, this fix still needs some work since |
Great, Thanks!!!! 👍 |
Huh. I thought I had pushed a 1.0.2 version at some point... I'll figure out what to include for a new release today. |
@ed-mejia I couldn't reproduce a problem where notifications were reporting the incorrect status, though I did encounter an issue where Can you test with |
Hi @nickoneill, I was able to recreate the issue again, Update pod from master, my pod config is just like: pod 'PermissionScope', :git => 'https://github.com/nickoneill/PermissionScope.git' On Simulator: Reset content and settings My Controller code: class PermissionsViewController: UIViewController {
//MARK: Properties
let pscope = PermissionScope()
override func viewDidLoad() {
super.viewDidLoad()
setupPermissions()
}
/// Private func to setup permission for this screen
private func setupPermissions() {
pscope.viewControllerForAlerts = self
pscope.addPermission(NotificationsPermission(notificationCategories: nil),
message: "We use this to send you\r\nspam and love notes")
pscope.onAuthChange = { (finished, results) in
print("got results \(results)")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func enablePushNotifications(sender: RoundedButton) {
pscope.requestNotifications()
}
} the console output after granting the permission:
|
Thanks for the excellent repro steps @ed-mejia, I can see the issue you're having now. Can you try again with the most updated pscope code? Use this in your podfile: pod 'PermissionScope', :head And I tested with a fresh project and the issue appears with our 1.0.1 version and fixed in the upcoming 1.0.2. Please let me know if you see anything different. |
@nickoneill I don't think the fixed code is in the repository or I'm doing something wrong 😕 I just create a fresh new project to be sure: Xcode 7.2, Apple Swift version 2.1.1 My pod file: # Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'PerTest' do
pod 'PermissionScope', :head
end run pod install, console output:
Opened the project run and test again same console output after permission being granted:
I attached the project here: |
Try pscope.onAuthChange = { (finished, results) in
print("got results \(results)")
print("statusNotifications \(self.pscope.statusNotifications())")
} Is it still |
@bre7 Yes the results are:
|
Here's what I'm seeing with your project @ed-mejia: I'm nearly ready to chalk this up to simulator weirdness (not the first time we've seen sim issues with permissions). It seems to work fine in plenty of other places. Care to run some of these and report your findings? |
@nickoneill I just ran the project on an iPhone 6 iOS 9.2 for the first time and the results were not successful just after calling requestNotifications for the first time:
So it's not a simulator issue, if you call requestNotifications again the results are ok, but its wrong from the beginning. |
I just tried to run the same project again with different bundle ids on the same device and the results were ok despite the fact the first time were wrong.... I took another iPhone 6 and I ran the project again for the very first time on that device and the results were:
So at the very very first time the app runs on the device it returns a wrong value, considering that the request of permission is a one shoot in the very first life time of the app this issue really matters because there is only one chance to display the actual status of that request. |
Alright, back to the drawing board then. I'll run through the code again and see if I can spot a race condition. |
@ed-mejia We were going through the I've moved the Let me know if this fixes the issue for you. I'll be releasing a 1.0.2 beta shortly, or you can continue using |
@nickoneill I used the test project that I attached here PermTest.zip .. updated Pod to head, run and still 😭
I did simulator reset, change bundle identifier, no luck PD: Sorry I closed the issue by mistake. |
Shit. Same deal with the test project and 1.0.2beta, I'll try again. At least we know where the issue is at this point. |
Opted for a slight different approach, now we just straight up delay 0.1s after |
Hey @nickoneill I can confirm that the onAuthChange callback is now returning the right value after authorising:
🎉 😃 |
Awesome :) Releasing here soon... |
Hi, I'm trying a very simple setup... but for some reason I always get _Unauthorized_ response to the notifications request, I'm running on Xcode 7.1, swift 2.1 Simulator iPhone 6, iOS 9.1
Code:
Console:
The text was updated successfully, but these errors were encountered: