uni-app develops WeChat applet, "Mini Program Privacy Agreement Development Guide" development plan, wx.getPrivacySetting, wx.onNeedPrivacyAuthorization method usage.

The pop-up code plug-in has been integrated,Plug and play,It takes five minutes to integrate into the project. Free download from the link below, everyone is welcome to comment and exchange 


WeChat Mini Program User Privacy Protection Agreement pop-up plug-in download

1. Privacy agreement development

Regarding the development of mini program privacy protocols, the official recently provided 3 demos, 3implementation methodsaccording toBusiness process selection:

Demo1: Demonstrates the use of wx.getPrivacySetting and <button open-type="agreePrivacyAuthorization"> to handle privacy pop-up logic on the homepage https://developers.weixin.qq .com/s/gi71sGm67hK0

Demo2: Demonstrates the use of wx.onNeedPrivacyAuthorization and <button open-type="agreePrivacyAuthorization"> to process privacy pop-up logic on multiple pages, and demonstrates how to handle simultaneous calls to multiple privacy interfaces. https://developers.weixin.qq.com/s/4X7yyGmQ7EKp

Demo3: Demonstrates how to use wx.onNeedPrivacyAuthorization, wx.requirePrivacyAuthorize, <button open-type="agreePrivacyAuthorization"> and <input type="nickname"> components together https://developers.weixin.qq.com/s/jX7xWGmA7UKa

Demo1

In the above situations, demo1 can be used to check when the mini program is started. If there is no authorization, a pop-up window will appear. If the user does not agree, the user will exit;

Or for a minimalist applet, such as clicking a button on a page to select an image, you can callwx.getPrivacySetting when processing the button event. If the user does not agree with the pop-up window, do nothing or give a toast. Next time the user clicks the button, check again and pop up the window again.

  • This is the simplest. The privacy protocol interface called is the least, only onewx.getPrivacySetting. (wx.openPrivacyContractdoes not count).
    The logic is to check the authorization status before calling any privacy interface. If authorized, do nothing, and if not authorized, a pop-up window will appear.

  • Features: The developer actively checks the pop-up window instead of being triggered by the privacy interface call.

  • Simple, minimal code.

  • Process: Active check->Pop-up window->User consent->Call privacy interface

  • Applicable scene:
  • The privacy interface is not called during the mini program startup process. In other words, the privacy interface needs to be called by the user's action, such as the user clicking a button to select a picture.
  • Mini programs with strong privacy requirements cannot be used by users without authorization, and users can exit directly.
  • Minimalist small program, such as just one page, or just calling a privacy interface.​   

Demo2

  • Demo2 is more complicated and requires the use ofwx.onNeedPrivacyAuthorization interface. The difference from demo1 is that the pop-up window is triggered by calling the privacy interface instead of being actively checked by the developer< /span>

    • Features:
  • The pop-up window is triggered by calling the privacy interface.
  • Complex and a lot of code.
  • Process: Call the privacy interface->Pop-up window (while the privacy interface is pending)->User agrees/disagree->The privacy interface returns success or failure
  • Applicable scene:
  • Common scenarios, multiple pages, multiple privacy interfaces.
  • Triggered passively, no need to care when the privacy interface is called.

Demo3

  • Demo3 is based on demo2 and has more callswx.requirePrivacyAuthorize. The official statement is that this interface is used to simulate privacy interface calls.

  • Features:

  1. The pop-up window can be triggered by calling the privacy interface, or it can be triggered bywx.requirePrivacyAuthorize
  2. Complex and a lot of code.
  3. Process: Call the privacy interface (wx.requirePrivacyAuthorize)->Pop-up window (while the privacy interface is pending)->User agrees/disagree->The privacy interface returns success or failure
  4. Compared with demo1, the same thing is that developers can actively trigger privacy pop-ups, but the difference is that demo3 is more complicated.
  5. Compared with demo2, the same point is that its logic is consistent with calling the real privacy interface, but the difference is that it provides developers with a more flexible mode that can actively trigger pop-up windows.
  6. You can think of demo3=demo1 + demo2
  • Applicable scene:
  1. Same as demo2.
  2. Privacy components without interfaces, such as <input type="nickname">
  3. More flexible requirements than demo2.

Forwx.requirePrivacyAuthorize interface, please do not limit this interface to debugging only during development. This interface can also be used online. Can be used to implement more flexible logic.

The above is my understanding of these three demos. If you have any ideas, please leave a message in the comment area for discussion.

Guess you like

Origin blog.csdn.net/weixin_45395283/article/details/132800706