How do I determine if a subscribing message user clickedAlways keep the choice above and never ask again
Background: A real business requirement arises to determine whether a user has clicked the hold option. The business happens not to count those users who have saved by default and choose to agree or cancel, which is the opposite of most requirements.
The earliest review of the documentation found that the requestSubscribeMessage first returned only interface failure/interface success (select Cancel/agree). Does not return the hold option. Then look at getSetting and see that there is an extra parameter
withSubscriptions | Boolean | Whether to obtain the subscription status of user subscription messages at the same time. Note: withSubscriptions only returns subscription messages if the user checked “always hold above options, never ask again” in the subscription panel. |
---|
If withSubscriptions is set to true, an additional object will be returned:
SubscriptionsSetting = {mainSwitch: true, itemSettings: {SYS_MSG_TYPE_INTERACTIVE: 'accept', / / a small game system subscribe message SYS_MSG_TYPE_RANK: 'accept' zun LzcQyW - edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: 'reject', / / ordinary disposable subscribe message ke_OZC_66gZxALLcsuI7ilCJSP2OJ2vWo2ooUPpkWrw: 'ban'}}Copy the code
You can see that mainSwitch is the mainSwitch, which can be turned off by setting > Settings in the upper right corner. After turning off, the interface will return fail: 20004, this is not what I need, because in the description, it only returns that the user has checked the subscription panel, “always keep the above selection, no longer ask, so the real machine test, switch to keep the above selection checked, and the print does have changes.
// uncheck subscriptionsSetting: {mainSwitch: true}Copy the code
SubscriptionsSetting: {mainSwitch: true, itemSettings: {[id]: 'accept',}, [id]: 'accept'}Copy the code
As you can see from the above, check the key value pair and ItemSettings for your subscription ID. So we can determine res. SubscriptionsSetting. [key] or subscriptionsSetting itemSettings whether to confirm the check. In addition, the value of mainSwitch and the popover selection when checked do not affect the structure, that is, even if the mainSwitch is closed, or a certain id value is reject, you can judge whether to keep the above selection. Use this to determine specific business requirements with a variety of combination judgments:
- Check no longer ask, prohibit push
- Check no query, enable push, do not receive
- Check no longer ask, enable push, receive
- If it is not checked, it will not be asked or received
- Unchecked no longer ask, receive