सामग्री पर जाएं

यूनिटी SDK बेसिक इंटीग्रेशन गाइड

इस सेक्शन में यह जानकारी दी गई है कि आप अपने एप्लिकेशन में पुशवूश यूनिटी SDK को कैसे इंटीग्रेट कर सकते हैं।

पूर्वापेक्षाएँ

Anchor link to

अपने ऐप में पुशवूश यूनिटी SDK को इंटीग्रेट करने के लिए, आपको निम्नलिखित की आवश्यकता होगी:

इंटीग्रेशन के चरण

Anchor link to

1. पुशवूश यूनिटी SDK डिपेंडेंसी जोड़ें

Anchor link to

यूनिटी में अपने Assets फ़ोल्डर में यूनिटी पुश नोटिफिकेशन प्लगइन इम्पोर्ट करें।

2. यूनिटी SDK इनिशियलाइज़ेशन

Anchor link to

एक PushNotificator.cs स्क्रिप्ट बनाएँ और इसे सीन में कैमरा ऑब्जेक्ट से अटैच करें। स्क्रिप्ट में:

  • एप्लिकेशन कोड और Firebase प्रोजेक्ट नंबर के साथ पुशवूश SDK को इनिशियलाइज़ करें।
  • पुश नोटिफिकेशन के लिए रजिस्टर करने के लिए अपने इनिशियलाइज़ेशन लॉजिक में RegisterForPushNotifications() को कॉल करें।
  • पुश रजिस्ट्रेशन इवेंट्स को मैनेज करने के लिए रजिस्ट्रेशन इवेंट हैंडलर जोड़ें:
PushNotificator.cs
using UnityEngine;
using UnityEngine.UI;
public class PushNotificator : MonoBehaviour {
void Start () {
Pushwoosh.ApplicationCode = "__YOUR_APP_ID__";
Pushwoosh.FcmProjectNumber = "__YOUR_FCM_SENDER_ID__";
Pushwoosh.Instance.OnRegisteredForPushNotifications += OnRegisteredForPushNotifications;
Pushwoosh.Instance.OnFailedToRegisteredForPushNotifications += OnFailedToRegisteredForPushNotifications;
Pushwoosh.Instance.RegisterForPushNotifications();
}
void OnRegisteredForPushNotifications(string token) {
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Received token: \n{0}", token);
}
void OnFailedToRegisteredForPushNotifications(string error) {
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Error ocurred while registering to push notifications: \n{0}", error);
}
}

जहाँ:

  • __YOUR_APP_ID__ पुशवूश कंट्रोल पैनल से एप्लिकेशन कोड है।
  • __YOUR_FCM_SENDER_ID__ Firebase कंसोल से Firebase प्रोजेक्ट नंबर है।

3. iOS नेटिव सेटअप

Anchor link to

3.1 कैपेबिलिटीज़

Anchor link to

अपने प्रोजेक्ट में पुश नोटिफिकेशन को सक्षम करने के लिए, आपको कुछ कैपेबिलिटीज़ जोड़ने की आवश्यकता है।

साइनिंग और कैपेबिलिटीज़ सेक्शन में, निम्नलिखित कैपेबिलिटीज़ जोड़ें:

  • Push Notifications
  • Background Modes। इस कैपेबिलिटी को जोड़ने के बाद, Remote notifications के लिए बॉक्स को चेक करें।

यदि आप टाइम सेंसिटिव नोटिफिकेशन (iOS 15+) का उपयोग करना चाहते हैं, तो Time Sensitive Notifications कैपेबिलिटी भी जोड़ें।

3.2 Info.plist

Anchor link to

अपने Runner/Info.plist में __PUSHWOOSH_DEVICE_API_TOKEN__ कुंजी को Pushwoosh डिवाइस API टोकन पर सेट करें:

info.plist
<key>Pushwoosh_API_TOKEN</key>
<string>__PUSHWOOSH_DEVICE_API_TOKEN__</string>

3.3 संदेश डिलीवरी ट्रैकिंग

Anchor link to

आपको अपने प्रोजेक्ट में एक नोटिफिकेशन सर्विस एक्सटेंशन टारगेट जोड़ना होगा। यह सटीक डिलीवरी ट्रैकिंग और iOS पर रिच मीडिया जैसी सुविधाओं के लिए आवश्यक है।

एक्सटेंशन टारगेट और उसके भीतर आवश्यक पुशवूश कोड जोड़ने के लिए नेटिव गाइड के चरणों का पालन करें।

4. Android नेटिव सेटअप

Anchor link to

4.1 Firebase कॉन्फ़िगरेशन फ़ाइल जोड़ें

Anchor link to

google-services.json फ़ाइल को अपनी प्रोजेक्ट डायरेक्टरी में Assets फ़ोल्डर में रखें।

4.2 बिल्ड सेटिंग्स एडजस्ट करें

Anchor link to

अपने Android बिल्ड प्रोफ़ाइल के Publishing Settings सेक्शन में Custom Main Manifest विकल्प को सक्षम करें।

4.3 पुशवूश मेटाडेटा जोड़ें

Anchor link to

अपने Assets/Plugins/Android/AndroidManifest.xml में <application> टैग के अंदर Pushwoosh डिवाइस API टोकन जोड़ें:

AndroidManifest.xml
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_DEVICE_API_TOKEN__" />

महत्वपूर्ण: सुनिश्चित करें कि आप अपने पुशवूश कंट्रोल पैनल में टोकन को सही ऐप का एक्सेस दें। और जानें

5. विंडोज स्टोर इंटीग्रेशन

Anchor link to
  1. निम्नलिखित कंटेंट के साथ अपनी Assets/ डायरेक्टरी में link.xml जोड़ें:
<linker>
<assembly fullname="PushSDK" preserve="all"/>
</linker>
  1. आपको एक्सपोर्ट किए गए विजुअल स्टूडियो प्रोजेक्ट में ऐप को स्टोर के साथ एसोसिएट करने की भी आवश्यकता है। सुनिश्चित करें कि आपका ऐप आपकी प्रकाशक पहचान से मेल खाने वाले प्रमाणपत्र के साथ हस्ताक्षरित है।

एक्सपोर्ट किए गए विजुअल स्टूडियो प्रोजेक्ट में अपने .appxmanifest के कैपेबिलिटीज़ टैब में इंटरनेट (क्लाइंट) कैपेबिलिटी को चुनें।

6. प्रोजेक्ट चलाएँ

Anchor link to
  1. प्रोजेक्ट को बिल्ड और रन करें।
  2. पुशवूश कंट्रोल पैनल पर जाएँ और एक पुश नोटिफिकेशन भेजें
  3. आपको ऐप में नोटिफिकेशन दिखना चाहिए।

विस्तारित इंटीग्रेशन

Anchor link to

इस स्तर पर, आपने पहले ही SDK को इंटीग्रेट कर लिया है और पुश नोटिफिकेशन भेज और प्राप्त कर सकते हैं। अब, आइए मुख्य कार्यक्षमता का पता लगाएँ

पुश नोटिफिकेशन इवेंट लिसनर

Anchor link to

पुशवूश SDK में दो इवेंट लिसनर हैं, जो पुश नोटिफिकेशन को संभालने के लिए डिज़ाइन किए गए हैं:

  • OnPushNotificationsReceived इवेंट तब ट्रिगर होता है, जब कोई पुश नोटिफिकेशन प्राप्त होता है
  • OnPushNotificationsOpened इवेंट तब ट्रिगर होता है, जब कोई उपयोगकर्ता नोटिफिकेशन खोलता है

आपको PushNotificator.cs में SDK के इनिशियलाइज़ेशन के ठीक बाद इन इवेंट लिसनर्स को सेटअप करना चाहिए:

PushNotificator.cs
using UnityEngine;
using UnityEngine.UI;
public class PushNotificator : MonoBehaviour {
void Start () {
Pushwoosh.ApplicationCode = "__YOUR_APP_ID__";
Pushwoosh.FcmProjectNumber = "__YOUR_FCM_SENDER_ID__";
Pushwoosh.Instance.OnPushNotificationsReceived += OnPushNotificationsReceived;
Pushwoosh.Instance.OnPushNotificationsOpened += OnPushNotificationsOpened;
Pushwoosh.Instance.RegisterForPushNotifications();
}
void OnPushNotificationsReceived(string payload) {
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Received push notificaiton: \n{0}", payload);
}
void OnPushNotificationsOpened(string payload) {
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Opened push notificaiton: \n{0}", payload);
}

उपयोगकर्ता कॉन्फ़िगरेशन

Anchor link to

व्यक्तिगत उपयोगकर्ता के व्यवहार और वरीयताओं पर ध्यान केंद्रित करके, आप व्यक्तिगत कंटेंट दे सकते हैं, जिससे उपयोगकर्ता की संतुष्टि और वफादारी बढ़ती है

public class Registration {
public void afterUserLogin(User user) {
// Set user ID
Pushwoosh.Instance.SetUserId(user.getId());
// Set user email
Pushwoosh.Instance.SetEmail(user.getEmail());
// Setting additional user information as tags for Pushwoosh
Pushwoosh.Instance.SetIntTag("Age", user.getAge());
Pushwoosh.Instance.SetStringTag("Name", user.getName());
Pushwoosh.Instance.SetStringTag("LastLoginDate", user.getLastLoginDate());
}
}

टैग्स

Anchor link to

टैग उपयोगकर्ताओं या उपकरणों को सौंपे गए की-वैल्यू पेयर होते हैं, जो वरीयताओं या व्यवहार जैसे गुणों के आधार पर सेगमेंटेशन की अनुमति देते हैं, जिससे लक्षित संदेश भेजना संभव हो जाता है।

public class UpdateUser {
public void afterUserUpdateProfile(User user) {
// Set list of favorite categories
Pushwoosh.Instance.SetListTag(
"favorite_categories": user.getFavoriteCategoriesList()
);
// Set payment information
Pushwoosh.Instance.SetStringTag("is_subscribed", user.isSubscribed());
Pushwoosh.Instance.SetStringTag("payment_status", user.getPaymentStatus());
Pushwoosh.Instance.SetStringTag("billing_address", user.getBillingAddress());
}
}

इवेंट्स

Anchor link to

इवेंट्स ऐप के भीतर विशिष्ट उपयोगकर्ता क्रियाएँ या घटनाएँ होती हैं जिन्हें व्यवहार का विश्लेषण करने और संबंधित संदेशों या क्रियाओं को ट्रिगर करने के लिए ट्रैक किया जा सकता है

public class Registration {
// Track login event
public void afterUserLogin(User user) {
Pushwoosh.Instance.PostEvent("login", new Dictionary<string, object>() {
{ "name", user.getName() },
{ "last_login", user.getLastLoginDate() }
});
}
public void afterUserPurchase(Product product) {
// Track purchase event
Pushwoosh.Instance.PostEvent("purchase", new Dictionary<string, object>() {
{ "product_id", product.getId() },
{ "product_name", product.getName() },
{ "price", product.getPrice() },
{ "quantity", product.getQuantity() }
});
}
}

समस्या निवारण

Anchor link to

यदि आपको इंटीग्रेशन प्रक्रिया के दौरान कोई समस्या आती है, तो कृपया समर्थन और समुदाय सेक्शन देखें।