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

iOS मोडल रिच मीडिया

Pushwoosh SDK संस्करण 6.7.5 से, आपके पास मोडल रिच मीडिया भेजने की क्षमता है।

हम नए मोडल रिच मीडिया पेश कर रहे हैं, जिन्हें अनुकूलित किया जा सकता है। नए मोडल रिच मीडिया स्क्रीन को पूरी तरह से ब्लॉक नहीं करते हैं और स्क्रीन के विभिन्न हिस्सों (ऊपर, नीचे, और केंद्र) में रखे जा सकते हैं।

रिच मीडिया पेजों के बारे में अधिक जानकारी के लिए, कृपया हमारी गाइड देखें।

कॉन्फ़िगरेशन

Anchor link to
//for silent push notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Pushwoosh.configure.handlePushReceived(userInfo)
completionHandler(.noData)
}

विकल्प 1: Info.plist कॉन्फ़िगरेशन

Anchor link to

मोडल रिच मीडिया के प्रदर्शन को सक्षम करने के लिए, अपने info.plist में Pushwoosh_RICH_MEDIA_STYLE पैरामीटर सेट करें और इसे MODAL_RICH_MEDIA मान निर्दिष्ट करें।

Info.plist:

<key>Pushwoosh_RICH_MEDIA_STYLE</key>
<string>MODAL_RICH_MEDIA</string>

विकल्प 2: प्रोग्रामेटिक कॉन्फ़िगरेशन (SDK 7.0.14+)

Anchor link to

आप अपने AppDelegate में रिच मीडिया प्रस्तुति शैली को प्रोग्रामेटिक रूप से भी कॉन्फ़िगर कर सकते हैं:

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Set modal presentation style
Pushwoosh.media.setRichMediaPresentationStyle(.modal)
// Configure modal window appearance
Pushwoosh.media.modalRichMedia.configure(
position: .PWModalWindowPositionBottom,
presentAnimation: .PWAnimationPresentFromBottom,
dismissAnimation: .PWAnimationDismissDown
)
Pushwoosh.configure.registerForPushNotifications()
return true
}

डिफ़ॉल्ट रूप से, मोडल रिच मीडिया स्क्रीन के केंद्र में नीचे-से-ऊपर की उपस्थिति एनीमेशन के साथ प्रदर्शित होगा।

मोडल रिच मीडिया पोजिशनिंग

Anchor link to

मोडल रिच मीडिया को स्क्रीन पर विभिन्न स्थानों पर रखा जा सकता है।

/**
Enum defining the possible positions for displaying a modal window.
- `PWModalWindowPositionTop`: The modal window appears at the top of the screen, within the safe area.
- `PWModalWindowPositionCenter`: The modal window appears at the center of the screen, within the safe area.
- `PWModalWindowPositionBottom`: The modal window appears at the bottom of the screen, within the safe area.
- `PWModalWindowPositionBottomSheet`: The modal window appears at the very bottom of the screen, ignoring the safe area.
- `PWModalWindowPositionDefault`: The default position is the center of the screen, within the safe area.
*/
typedef NS_ENUM(NSInteger, ModalWindowPosition) {
PWModalWindowPositionTop, // Appears at the top of the screen (within safe area)
PWModalWindowPositionCenter, // Appears at the center of the screen (within safe area)
PWModalWindowPositionBottom, // Appears at the bottom of the screen (within safe area)
PWModalWindowPositionBottomSheet, // Appears at the very bottom of the screen (ignores safe area)
PWModalWindowPositionFullScreen, // Fullscreen, ignores safe area insets
PWModalWindowPositionDefault // Default position (center of the screen, within safe area)
};

नीचे दिया गया उदाहरण स्क्रीन के शीर्ष पर प्रदर्शित एक मोडल रिच मीडिया दिखाता है।

मोडल रिच मीडिया शो एनिमेशन में शामिल हैं:

typedef NS_ENUM(NSInteger, PresentModalWindowAnimation) {
PWAnimationPresentFromBottom,
PWAnimationPresentFromTop,
PWAnimationPresentFromRight,
PWAnimationPresentFromLeft,
PWAnimationPresentNone
};

मोडल रिच मीडिया क्लोज एनिमेशन में शामिल हैं:

typedef NS_ENUM(NSInteger, DismissModalWindowAnimation) {
PWAnimationDismissDown,
PWAnimationDismissUp,
PWAnimationDismissLeft,
PWAnimationDismissRight,
PWAnimationCurveEaseInOut,
PWAnimationDismissNone,
/**
* Default dismiss animation is `PWAnimationCurveEaseInOut`
*/
PWAnimationDismissDefault
};

नीचे दिया गया उदाहरण स्क्रीन के नीचे मोडल रिच मीडिया को बाएं-से-दाएं शो एनीमेशन और दाईं ओर क्लोज एनीमेशन के साथ प्रदर्शित करता है:

मोडल रिच मीडिया के लिए अतिरिक्त पैरामीटर

Anchor link to

मोडल रिच मीडिया को प्रदर्शित करने के लिए अतिरिक्त मापदंडों में कंपन प्रकार की हैप्टिक प्रतिक्रिया जोड़ना, स्वाइप जेस्चर को सक्षम करना, और एक निर्दिष्ट अवधि के बाद एक स्वचालित क्लोज टाइमर सेट करना शामिल है।

// Haptic Feedback Type
Pushwoosh.media.modalRichMedia.setHapticFeedbackType(.PWHapticFeedbackLight)
// Swipe directions to dismiss
Pushwoosh.media.modalRichMedia.setDismissSwipeDirections([
NSNumber(value: DismissSwipeDirection.PWSwipeDismissDown.rawValue),
NSNumber(value: DismissSwipeDirection.PWSwipeDismissUp.rawValue)
])
// Set Rich Media corner radius
let topCorners = PWCornerTypeTopLeft.rawValue | PWCornerTypeTopRight.rawValue
Pushwoosh.media.modalRichMedia.setCornerType(CornerType(rawValue: topCorners), withRadius: 16)
// Close Modal Rich Media after N seconds
Pushwoosh.media.modalRichMedia.closeAfter(3)

हैप्टिक फीडबैक प्रकार:

typedef NS_ENUM(NSInteger, HapticFeedbackType) {
PWHapticFeedbackLight, // Light vibration feedback
PWHapticFeedbackMedium, // Medium vibration feedback
PWHapticFeedbackHard, // Strong vibration feedback
PWHapticFeedbackNone // Vibration is off (default)
};

स्वाइप दिशा-निर्देश:

typedef NS_ENUM(NSInteger, DismissSwipeDirection) {
PWSwipeDismissDown,
PWSwipeDismissUp,
PWSwipeDismissLeft,
PWSwipeDismissRight,
PWSwipeDismissNone
};

PWRichMediaPresentingDelegate

Anchor link to

PWRichMediaPresentingDelegate के डेलीगेट तरीकों को लागू करके आप मोडल रिच मीडिया की कतार का प्रबंधन कर सकते हैं। इस कार्यक्षमता का उपयोग करते समय, मोडल रिच मीडिया क्रमिक रूप से प्रस्तुत किए जाते हैं, और अगला तब तक प्रदर्शित नहीं होगा जब तक कि उपयोगकर्ता वर्तमान वाले को बंद नहीं कर देता। एक बार जब उपयोगकर्ता प्रस्तुत रिच मीडिया को बंद कर देता है, तो अगला, जो एक अलग पुश नोटिफिकेशन का हिस्सा था, दिखाया जाएगा।

import UIKit
import PushwooshFramework
@main
class AppDelegate: UIResponder, UIApplicationDelegate, PWRichMediaPresentingDelegate {
var richMediaQueue: [PWRichMedia] = []
var isPresenting = false
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Configure modal rich media
Pushwoosh.media.setRichMediaPresentationStyle(.modal)
Pushwoosh.media.modalRichMedia.configure(
position: .PWModalWindowPositionBottom,
presentAnimation: .PWAnimationPresentFromBottom,
dismissAnimation: .PWAnimationDismissDown
)
// Set delegate
Pushwoosh.media.modalRichMedia.delegate = self
Pushwoosh.configure.registerForPushNotifications()
return true
}
// MARK: - PWRichMediaPresentingDelegate
func richMediaManager(_ richMediaManager: PWRichMediaManager, shouldPresent richMedia: PWRichMedia) -> Bool {
if !richMediaQueue.contains(where: { $0 === richMedia }) {
richMediaQueue.append(richMedia)
}
return !isPresenting
}
func richMediaManager(_ richMediaManager: PWRichMediaManager, didPresent richMedia: PWRichMedia) {
isPresenting = true
}
func richMediaManager(_ richMediaManager: PWRichMediaManager, didClose richMedia: PWRichMedia) {
isPresenting = false
if let idx = richMediaQueue.firstIndex(where: { $0 === richMedia }) {
richMediaQueue.remove(at: idx)
}
// Present next rich media in queue
if let nextRichMedia = richMediaQueue.first {
Pushwoosh.media.modalRichMedia.present(nextRichMedia)
}
}
func richMediaManager(_ richMediaManager: PWRichMediaManager, presentingDidFailFor richMedia: PWRichMedia, withError error: Error) {
richMediaManager(richMediaManager, didClose: richMedia)
}
}