การจัดการความยินยอมของผู้ใช้
Pushwoosh รองรับการปฏิบัติตามกฎระเบียบด้านความเป็นส่วนตัว (เช่น GDPR, CCPA) โดยอนุญาตให้นักพัฒนาควบคุมเวลาที่ SDK เริ่มการสื่อสารกับเซิร์ฟเวอร์ของ Pushwoosh ซึ่งจะช่วยให้มั่นใจได้ว่าจะไม่มีการรวบรวมข้อมูลใดๆ ก่อนที่ผู้ใช้จะให้ความยินยอมอย่างชัดแจ้ง
ภาพรวม
Anchor link toโดยค่าเริ่มต้น Pushwoosh SDK จะเริ่มการสื่อสารและรวบรวมข้อมูลอุปกรณ์ทันทีเมื่อเริ่มต้น อย่างไรก็ตาม คุณสามารถเปลี่ยนพฤติกรรมนี้เพื่อไม่ให้มีการสื่อสารใดๆ เกิดขึ้นจนกว่าผู้ใช้จะให้ความยินยอม
ด้วยการตั้งค่านี้:
-
หากผู้ใช้ให้ความยินยอม SDK จะเริ่มต้นและเริ่มรวบรวมข้อมูล
-
หากผู้ใช้ไม่ให้ความยินยอม SDK จะยังคงไม่ทำงานและจะไม่รวบรวมข้อมูลใดๆ
-
หากผู้ใช้ถอนความยินยอมในภายหลัง SDK จะหยุดกิจกรรมทั้งหมดและตัดการเชื่อมต่อจากเซิร์ฟเวอร์
Pushwoosh มีกลไกในการจัดการโฟลว์นี้ใน iOS, Android และ Unity
ปิดใช้งานการสื่อสารกับเซิร์ฟเวอร์ SDK เมื่อเริ่มต้น
Anchor link toโดยค่าเริ่มต้น การสื่อสารกับ SDK จะถูกเปิดใช้งาน หากต้องการปิดใช้งานการสื่อสารทั้งหมดกับเซิร์ฟเวอร์ Pushwoosh จนกว่าผู้ใช้จะให้ความยินยอมอย่างชัดแจ้ง ให้เพิ่มคีย์ต่อไปนี้ลงในไฟล์ Info.plist ของคุณ:
<key>Pushwoosh_ALLOW_SERVER_COMMUNICATION</key><false/>ตรวจสอบสถานะการสื่อสาร
Anchor link toใช้วิธีการต่อไปนี้เพื่อตรวจสอบว่าขณะนี้อนุญาตให้มีการสื่อสารหรือไม่:
import SwiftUIimport PushwooshFramework
var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowedprint("isServerCommunicationAllowed: ", serverCommunicationAllowed)import PushwooshFramework
var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowedprint("isServerCommunicationAllowed: ", serverCommunicationAllowed)#import <PushwooshFramework/PushwooshFramework.h>
BOOL serverCommunicationAllowed = [PWCoreServerCommunicationManager sharedInstance].isServerCommunicationAllowed;NSLog(@"isServerCommunicationAllowed: %d", serverCommunicationAllowed);เปิดใช้งานการสื่อสาร SDK หลังจากได้รับความยินยอม
Anchor link toเมื่อผู้ใช้ให้ความยินยอมแล้ว ให้เปิดใช้งานการสื่อสารดังนี้:
import SwiftUIimport PushwooshFramework
Pushwoosh.sharedInstance().startServerCommunication()import PushwooshFramework
Pushwoosh.sharedInstance().startServerCommunication()#import <PushwooshFramework/PushwooshFramework.h>
[[Pushwoosh sharedInstance] startServerCommunication];ลงทะเบียนเพื่อรับ push notifications
Anchor link toเมื่อเปิดใช้งานการสื่อสารแล้ว ให้ลงทะเบียนเพื่อรับ push notifications อย่างชัดแจ้ง:
import SwiftUIimport PushwooshFramework
Pushwoosh.sharedInstance().registerForPushNotifications()import PushwooshFramework
Pushwoosh.sharedInstance().registerForPushNotifications()#import <PushwooshFramework/PushwooshFramework.h>
[[Pushwoosh sharedInstance] registerForPushNotifications];ปิดใช้งานการสื่อสาร
Anchor link toหากต้องการหยุดการสื่อสารกับเซิร์ฟเวอร์ Pushwoosh (เช่น หากผู้ใช้เพิกถอนความยินยอม):
import SwiftUIimport PushwooshFramework
Pushwoosh.sharedInstance().stopServerCommunication()import PushwooshFramework
Pushwoosh.sharedInstance().stopServerCommunication()#import <PushwooshFramework/PushwooshFramework.h>
[[Pushwoosh sharedInstance] stopServerCommunication];Android
Anchor link toปิดใช้งานการสื่อสารกับเซิร์ฟเวอร์ SDK เมื่อเริ่มต้น
Anchor link toโดยค่าเริ่มต้น การสื่อสารจะถูกเปิดใช้งาน เพื่อป้องกันไม่ให้ข้อมูลใดๆ ถูกส่งไปยังเซิร์ฟเวอร์ Pushwoosh จนกว่าจะได้รับความยินยอมจากผู้ใช้ ให้เพิ่มข้อมูลต่อไปนี้ลงใน AndroidManifest.xml ของคุณ:
<meta-data android:name="com.pushwoosh.allow_server_communication" android:value="false" />ตรวจสอบสถานะการสื่อสาร
Anchor link toใช้วิธีการต่อไปนี้เพื่อตรวจสอบว่าขณะนี้อนุญาตให้มีการสื่อสารกับเซิร์ฟเวอร์หรือไม่:
import com.pushwoosh.Pushwoosh;
boolean isCommunicationEnabled = Pushwoosh.getInstance().isServerCommunicationAllowed();Log.d("Pushwoosh", "Communication enabled = " + isCommunicationEnabled);import com.pushwoosh.Pushwoosh
val isCommunicationEnabled = Pushwoosh.getInstance().isServerCommunicationAllowed()Log.d("Pushwoosh", "Communication enabled = $isCommunicationEnabled")เปิดใช้งานการสื่อสาร SDK หลังจากได้รับความยินยอม
Anchor link toเมื่อผู้ใช้ให้ความยินยอมแล้ว ให้เปิดใช้งานการสื่อสารดังนี้:
import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().startServerCommunication();import com.pushwoosh.Pushwoosh
Pushwoosh.getInstance().startServerCommunication()ลงทะเบียนเพื่อรับ push notifications
Anchor link toหลังจากเปิดใช้งานการสื่อสารแล้ว ให้ลงทะเบียนเพื่อรับ push notifications อย่างชัดแจ้ง:
import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().registerForPushNotifications();import com.pushwoosh.Pushwoosh
Pushwoosh.getInstance().registerForPushNotifications()ปิดใช้งานการสื่อสาร
Anchor link toหากต้องการหยุดการสื่อสารกับเซิร์ฟเวอร์ Pushwoosh (เช่น หากผู้ใช้เพิกถอนความยินยอม):
import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().stopServerCommunication();import com.pushwoosh.Pushwoosh
Pushwoosh.getInstance().stopServerCommunication()Unity
Anchor link toปิดใช้งานการสื่อสารกับเซิร์ฟเวอร์ SDK เมื่อเริ่มต้น
Anchor link toโดยค่าเริ่มต้น การสื่อสารกับ SDK จะถูกเปิดใช้งาน หากต้องการปิดใช้งานการสื่อสารทั้งหมดกับเซิร์ฟเวอร์ Pushwoosh จนกว่าผู้ใช้จะให้ความยินยอมอย่างชัดแจ้ง ให้ใช้การตั้งค่าเฉพาะแพลตฟอร์ม:
Android
เพิ่มข้อมูลต่อไปนี้ลงในโปรเจกต์ Unity ของคุณที่ AndroidManifest.xml:
<meta-data android:name="com.pushwoosh.allow_server_communication" android:value="false" />iOS
แก้ไข Info.plist:
<key>Pushwoosh_ALLOW_SERVER_COMMUNICATION</key><false/>หมายเหตุ: คุณต้องเปิดใช้งานการสื่อสารก่อนที่จะเรียก RegisterForPushNotifications
ตรวจสอบสถานะการสื่อสาร
Anchor link toใช้วิธีการต่อไปนี้เพื่อตรวจสอบว่าขณะนี้อนุญาตให้มีการสื่อสารกับเซิร์ฟเวอร์หรือไม่:
bool enabled = Pushwoosh.Instance.IsCommunicationEnabled();เปิดใช้งานการสื่อสาร SDK หลังจากได้รับความยินยอม
Anchor link toหากต้องการเปิดใช้งานการสื่อสารหลังจากได้รับความยินยอม:
Pushwoosh.Instance.SetCommunicationEnabled(true);ลงทะเบียนเพื่อรับ push notifications
Anchor link toเมื่อเปิดใช้งานการสื่อสารแล้ว คุณสามารถลงทะเบียนอุปกรณ์เพื่อรับ push notifications ได้:
Pushwoosh.Instance.RegisterForPushNotifications();ปิดใช้งานการสื่อสาร
Anchor link toหากต้องการหยุดการสื่อสารกับเซิร์ฟเวอร์ Pushwoosh (เช่น หากผู้ใช้เพิกถอนความยินยอม):
Pushwoosh.Instance.SetCommunicationEnabled(false);Web Push
Anchor link toปิดใช้งานการสมัครรับข้อมูลอัตโนมัติเมื่อเริ่มต้น
Anchor link toโดยค่าเริ่มต้น Pushwoosh SDK จะแสดงหน้าต่างขอสมัครรับข้อมูล (subscription prompt) ของเบราว์เซอร์ทันทีที่เริ่มต้น เพื่อป้องกันไม่ให้ SDK แสดงหน้าต่างขอสมัครรับข้อมูลโดยอัตโนมัติเมื่อเริ่มต้น ให้ตั้งค่าพารามิเตอร์ communicationEnabled เป็น false ในการเรียก init
<script type="text/javascript" src="//cdn.pushwoosh.com/webpush/v3/pushwoosh-web-notifications.js" async></script><script type="text/javascript"> var Pushwoosh = Pushwoosh || []; Pushwoosh.push(['init', { // other initialization parameters... communicationEnabled: false, // Disable communication to prevent automatic subscription prompts }]);</script>เปิดใช้งานการสมัครรับข้อมูลหลังจากได้รับความยินยอม
Anchor link toเมื่อคุณปิดใช้งานการสมัครรับข้อมูลอัตโนมัติแล้ว คุณสามารถแจ้งให้ผู้ใช้สมัครรับข้อมูลได้ตลอดเวลา เมื่อผู้ใช้ตกลงที่จะรับ push notifications (เช่น โดยการคลิกปุ่ม “Subscribe” บน UI ที่คุณกำหนดเอง) คุณสามารถเปิดใช้งานการสื่อสารได้โดยการเรียกเมธอด setCommunicationEnabled การเรียก Pushwoosh.setCommunicationEnabled(true) จะเป็นการเปิดใช้งานการสื่อสารกับบริการของ Pushwoosh เมื่อเปิดใช้งานแล้ว SDK จะดำเนินการแสดงหน้าต่างขออนุญาตของเบราว์เซอร์
Pushwoosh.setCommunicationEnabled(true) .then(() => { console.log('User is subscribed to push notifications.'); }) .catch((error) => { console.error('Error subscribing user:', error); });ปิดใช้งานการสื่อสาร
Anchor link toหากต้องการหยุดการสื่อสารกับบริการของ Pushwoosh (เช่น หากผู้ใช้เพิกถอนความยินยอม) ให้เรียก setCommunicationEnabled ด้วยค่า false
Pushwoosh.setCommunicationEnabled(false);