简体   繁体   中英

`pushDisallowed` and `Decision: Absolutely Must Not Proceed` on iPhone after some testing/debugging with background pushes

I am creating a Xamarin Forms app which is using background pushes via Azure Notification Hub. The app is targeting Android and iOS and after some initial prototyping and testing everything worked fine on both platforms. For iOS I am sending pushes with the following content:

{ "aps": { "content-available": 1, "apns-priority": 5, "sound": "", "badge": 0 }, "id": 10, "title": "PushDemo", "message": "Hello #10!" }

In my AppDelegate the DidReceiveRemoteNotification method did get called no matter if the app was active, in the background or completely closed. I then create a visible notification manually via code and show it to the user (and because I also need to execute some other logic I do not use "alert" directly in the push).

I then started implementing all the platform-specific logic in the Android project and there I did send a bunch of test-notifications via my backend-service where also my iPhone was still registered from the prototying phase. So I saw my iPhone also receiving all the test-pushes while I was testing the Android app. After finishing the Android side I got back to iOS and also implemented everything there, still working as expected. But soon after that the iPhone stopped receiving my pushes.
After investigating I found out that the DidReceiveRemoteNotification is not called anymore, no matter the state of the app, only the WillPresentNotification in my UNUserNotificationCenterDelegate is called if the app is active in the foreground.
After some more investigation (and verifying my test-app using the same code is still working completely) I saw that everything is working (eg badge number update) also in the background except calling my handler in code.
I then dug through the device logs and found the following after a push is received:

dasd[93]: com.apple.pushLaunch.com.Company.MyApp:AB795D:[ {name: ApplicationPolicy, policyWeight: 50.000, response: {Decision: Absolutely Must Not Proceed, Score: 0.00, Rationale: [{[pushDisallowed]: Required:0.00, Observed:1.00},]}} ], FinalDecision: Absolutely Must Not Proceed}

(BTW: I had to use the Mac to get that, the device log in VS did not show the part after the [ )

I guess the power saver of my iPhone deemed my app to pollute my phone as a lot of notifications where received and not interacted with.

How can I tell my iPhone to allow those notifications again?

I had a similar problem and solved it by removing the sound key, ie "sound": "" , from the content to be sent. If you look into the docs for "content-available": 1 :

The background notification flag. To perform a silent background update, specify the value 1 and don't include the alert, badge, or sound keys in your payload. See Pushing Background Updates to Your App.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM