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

CocoaPods के साथ InboxKit सेटअप करें

iOS SDK 7.0.40 से उपलब्ध।

InboxKit, PushwooshXCFramework पॉड के एक वैकल्पिक सबस्पेक के रूप में आता है। आपको मुख्य SDK को पहले से इंटीग्रेट करना होगा; यदि आप शुरुआत से शुरू कर रहे हैं, तो पहले बेसिक इंटीग्रेशन गाइड का पालन करें।

InboxKit पॉड जोड़ें

Anchor link to
  1. अपनी Podfile खोलें और अपने ऐप टारगेट में InboxKit सबस्पेक जोड़ें:
target 'MyApp' do
use_frameworks!
pod 'PushwooshXCFramework'
pod 'PushwooshXCFramework/PushwooshInboxKit'
end
  1. अपनी प्रोजेक्ट डायरेक्टरी से pod install चलाएँ:
Terminal window
pod install
  1. जेनरेट की गई .xcworkspace फ़ाइल खोलें। InboxKit अब मुख्य SDK के साथ लिंक हो गया है।

इनबॉक्स दिखाएँ

Anchor link to

इनबॉक्स कंट्रोलर को किसी भी नेविगेशन फ्लो में जोड़ें। डिफ़ॉल्ट कॉन्फ़िगरेशन तीन मानक सेल प्रकारों के साथ एक काम करने वाला इनबॉक्स प्राप्त करने के लिए पर्याप्त है:

import PushwooshInboxKit
let inboxVC = PushwooshInboxKitViewController()
navigationController?.pushViewController(inboxVC, animated: true)

इनबॉक्स को कस्टमाइज़ करें

Anchor link to

Swift में, कंट्रोलर को PushwooshInboxKitAttributes वैल्यू टाइप के माध्यम से कॉन्फ़िगर करें। Objective-C में, कंट्रोलर पर @objc-फ्रेंडली सेटर्स का उपयोग करें — PushwooshInboxKitAttributes एक Swift स्ट्रक्ट है और इसे ब्रिज नहीं किया गया है।

var attributes = PushwooshInboxKitAttributes()
attributes.pullToRefreshEnabled = true
attributes.swipeToDeleteEnabled = true
attributes.pinningEnabled = true
attributes.style.unreadBadgeColor = .systemBlue
attributes.style.titleFont = .systemFont(ofSize: 17, weight: .semibold)
let inboxVC = PushwooshInboxKitViewController(attributes: attributes)

Style स्ट्रक्ट डिफ़ॉल्ट सेल द्वारा उपयोग किए जाने वाले सभी रंगों, फ़ॉन्ट, कॉर्नर रेडिआई और डेट फ़ॉर्मेटर को एक्सपोज़ करता है। प्रत्येक मान डिफ़ॉल्ट रूप से एक Apple सिमेंटिक रंग है, इसलिए इनबॉक्स सिस्टम डार्क मोड पर स्वचालित रूप से प्रतिक्रिया करता है।

कस्टम-स्टाइल वाला InboxKit फ़ीड जिसमें शीर्षक और अपठित संकेतक पर ब्रांड रंग लागू किए गए हैं

PushwooshInboxKitAttributes.Style के माध्यम से लागू एक कस्टम थीम के साथ कैप्शन वाला सेल।

टैप और रिफ्रेश को हैंडल करें

Anchor link to

उपयोगकर्ता की क्रियाओं और रिफ्रेश इवेंट्स पर प्रतिक्रिया करने के लिए PushwooshInboxKitDelegate का पालन करें। प्रत्येक मेथड का एक डिफ़ॉल्ट कार्यान्वयन होता है, इसलिए आप केवल वही ओवरराइड करते हैं जिसकी आपको आवश्यकता है:

final class InboxCoordinator: NSObject, PushwooshInboxKitDelegate {
func inboxKit(_ vc: PushwooshInboxKitViewController,
didSelect message: PWInboxMessageProtocol) -> Bool {
// Return true to let the SDK open the message URL or richmedia.
// Return false if you handled the tap entirely (e.g. routed to a custom screen).
return true
}
func inboxKit(_ vc: PushwooshInboxKitViewController,
didRefreshWith messages: [PWInboxMessageProtocol],
error: Error?) {
// Show your own empty / error state here if needed.
}
}
inboxVC.delegate = inboxCoordinator

SDK कंट्रोलर पर @objc मेथड के रूप में बल्क ऑपरेशन भेजता है, ताकि आप उन्हें सीधे UIBarButtonItem से जोड़ सकें:

let markAll = UIBarButtonItem(
image: UIImage(systemName: "checkmark.circle"),
style: .plain,
target: inboxVC,
action: #selector(PushwooshInboxKitViewController.markAllAsRead)
)
let clearRead = UIBarButtonItem(
image: UIImage(systemName: "trash"),
style: .plain,
target: inboxVC,
action: #selector(PushwooshInboxKitViewController.clearReadMessages)
)
inboxVC.navigationItem.rightBarButtonItems = [clearRead, markAll]

अगले कदम

Anchor link to