iOS মোডাল রিচ মিডিয়া
Pushwoosh SDK সংস্করণ 6.7.5 থেকে, আপনার কাছে মোডাল রিচ মিডিয়া পাঠানোর ক্ষমতা রয়েছে।
আমরা নতুন মোডাল রিচ মিডিয়া চালু করছি, যা কাস্টমাইজ করা যায়। নতুন মোডাল রিচ মিডিয়া স্ক্রিনকে পুরোপুরি ব্লক করে না এবং স্ক্রিনের বিভিন্ন অংশে (উপরে, নীচে এবং কেন্দ্রে) অবস্থান করানো যায়।
রিচ মিডিয়া পেজ সম্পর্কে আরও তথ্যের জন্য, অনুগ্রহ করে আমাদের গাইড দেখুন।
কনফিগারেশন
Anchor link to//for silent push notificationsfunc application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Pushwoosh.sharedInstance().handlePushReceived(userInfo) completionHandler(.noData)}১. মোডাল রিচ মিডিয়া প্রদর্শন সক্ষম করতে, আপনার info.plist-এ Pushwoosh_RICH_MEDIA_STYLE প্যারামিটার সেট করুন এবং এটিকে MODAL_RICH_MEDIA মান দিন।
Info.plist:
<key>Pushwoosh_RICH_MEDIA_STYLE</key><string>MODAL_RICH_MEDIA</string>২. ডিফল্টরূপে, মোডাল রিচ মিডিয়া স্ক্রিনের কেন্দ্রে নীচ থেকে উপরে প্রদর্শিত হওয়ার অ্যানিমেশন সহ প্রদর্শিত হবে।
৩. মোডাল রিচ মিডিয়ার প্রদর্শন কনফিগার করতে (স্ক্রিনের অবস্থান, শো অ্যানিমেশন, ক্লোজ অ্যানিমেশন), আপনাকে নিম্নলিখিত মেথডটি ব্যবহার করতে হবে:
// Modal Rich Media ConfigurationPWModalWindowConfiguration.shared().configureModalWindow(with: .PWModalWindowPositionCenter, present: .PWAnimationPresentFromBottom, dismiss: .PWAnimationDismissUp)মোডাল রিচ মিডিয়া পজিশনিং
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 TypePWModalWindowConfiguration.shared().setPresent(.PWHapticFeedbackLight)
/**enum HapticFeedbackType
typedef NS_ENUM(NSInteger, HapticFeedbackType) { PWHapticFeedbackLight, // Light vibration feedback PWHapticFeedbackMedium, // Medium vibration feedback PWHapticFeedbackHard, // Strong vibration feedback
/** * Vibration is off by default. */ PWHapticFeedbackNone};*/
// Swipe directionslet directions: [NSNumber] = [ NSNumber(value: DismissSwipeDirection.PWSwipeDismissDown.rawValue), NSNumber(value: DismissSwipeDirection.PWSwipeDismissUp.rawValue)]PWModalWindowConfiguration.shared().setDismissSwipeDirections(directions)
/**typedef NS_ENUM(NSInteger, DismissSwipeDirection) { PWSwipeDismissDown, PWSwipeDismissUp, PWSwipeDismissLeft, PWSwipeDismissRight, PWSwipeDismissNone};*/
// Set Rich Media corner radiusPWModalWindowConfiguration.shared().setCornerType([.PWCornerTypeTopLeft, .PWCornerTypeBottomRight], withRadius: 30.0)
// Close Modal Rich Media after N secondsPWModalWindowConfiguration.shared().closeModalWindow(after: 3)PWRichMediaPresentingDelegate
Anchor link toমোডাল রিচ মিডিয়ার কিউ পরিচালনা করতে, আপনাকে PWRichMediaPresentingDelegate-এর ডেলিগেট মেথডগুলি প্রয়োগ করতে হবে। এই কার্যকারিতা ব্যবহার করার সময়, মোডাল রিচ মিডিয়া ক্রমানুসারে উপস্থাপিত হয়, এবং ব্যবহারকারী বর্তমানটি বন্ধ না করা পর্যন্ত পরবর্তীটি প্রদর্শিত হবে না। ব্যবহারকারী উপস্থাপিত রিচ মিডিয়া বন্ধ করার পরে, পরবর্তীটি, যা একটি ভিন্ন পুশ নোটিফিকেশনের অংশ ছিল, তা দেখানো হবে।
এই কার্যকারিতা প্রয়োগ করতে, নীচে দেওয়া কোডটি ব্যবহার করুন:
import UIKitimport PushwooshFramework
class ViewController: UIViewController {
override func viewDidLoad() { super.viewDidLoad()
PWRichMediaManager.shared().delegate = ChainedRichMediaPresentingDelegate.init(queue: [], inApp: false) }}
class ChainedRichMediaPresentingDelegate: NSObject, PWRichMediaPresentingDelegate {
var queue: [PWRichMedia] var inAppIsPresenting: Bool
init(queue: [PWRichMedia], inApp: Bool) { self.queue = queue self.inAppIsPresenting = inApp super.init() // can actually be omitted in this example because will happen automatically. }
convenience override init() { self.init(queue: [], inApp: false) }
func richMediaManager(_ richMediaManager: PWRichMediaManager!, shouldPresent richMedia: PWRichMedia!) -> Bool { if !queue.contains(where: { $0 === richMedia }) { queue.append(richMedia) } return !inAppIsPresenting }
func richMediaManager(_ richMediaManager: PWRichMediaManager!, didPresent richMedia: PWRichMedia!) { inAppIsPresenting = true }
func richMediaManager(_ richMediaManager: PWRichMediaManager!, didClose richMedia: PWRichMedia!) { inAppIsPresenting = false
if let idx = queue.firstIndex(where: { $0 === richMedia }) { queue.remove(at: idx) }
if ((queue.count) != 0) { PWModalWindowConfiguration.shared().presentModalWindow(queue.first!) } }
func richMediaManager(_ richMediaManager: PWRichMediaManager!, presentingDidFailFor richMedia: PWRichMedia!, withError error: Error!) { self.richMediaManager(richMediaManager, didClose: richMedia) }}