# iOS কাস্টম ফোরগ্রাউন্ড পুশ নোটিফিকেশন

সংস্করণ 6.10.0 থেকে, আপনি `PushwooshForegroundPush` মডিউলটি সংহত করতে পারেন যাতে নেটিভ iOS সিস্টেম অ্যালার্ট নিষ্ক্রিয় থাকা অবস্থায় ফোরগ্রাউন্ড পুশ নোটিফিকেশন কাস্টমাইজ করা যায়।

### ১. নেটিভ ফোরগ্রাউন্ড পুশ অ্যালার্ট নিষ্ক্রিয় করুন

আপনার `Info.plist`-এ `Pushwoosh_SHOW_ALERT = false` যোগ করুন।

```xml
<key>Pushwoosh_SHOW_ALERT</key>
<false/>
```

### ২. `PushwooshForegroundPush` মডিউল সংহত করা

**সুইফট প্যাকেজ ম্যানেজার**
<img src="/spm-foreground-push-ios.webp" alt=""/>

<Aside type="caution" title="গুরুত্বপূর্ণ">
`PushwooshFramework`, `PushwooshCore`, `PushwooshBridge`, এবং `PushwooshLiveActivities` মডিউলগুলো **আবশ্যক**।
</Aside>

**কোকোপডস**
```bash
# Uncomment the next line to define a global platform for your project
# platform :ios, '13.0'

target 'MyApp' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  pod 'PushwooshXCFramework'
  pod 'PushwooshFramework/PushwooshForegroundPush'

end
```

### ৩. AppDelegate-এ `PushwooshForegroundPush` কনফিগারেশন যোগ করুন

```swift
import UIKit
import PushwooshFramework
import PushwooshForegroundPush

@main
class AppDelegate: UIResponder, UIApplicationDelegate, PWMessagingDelegate, PWForegroundPushDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        Pushwoosh.ForegroundPush.foregroundNotificationWith(style: .style1,
                                                            duration: 5,
                                                            vibration: .notification,
                                                            disappearedPushAnimation: .balls)
        
        Pushwoosh.ForegroundPush.delegate = self
        
        return true
    }

    func pushwoosh(_ pushwoosh: Pushwoosh, onMessageReceived message: PWMessage) {
        if let payload = message.payload {
          // Pushwoosh method
          Pushwoosh.ForegroundPush.showForegroundPush(userInfo: payload)
        }
    }
}
```

`foregroundNotificationWith` মেথড ব্যবহার করে

`foregroundNotificationWith` মেথডটি আপনাকে কনফিগারযোগ্য স্টাইল, সময়কাল এবং হ্যাপটিক ফিডব্যাক সহ একটি কাস্টম ফোরগ্রাউন্ড পুশ নোটিফিকেশন প্রদর্শন করতে দেয়।

মেথড সিগনেচার (সুইফট / অবজেক্টিভ-সি):

```swift
@objc
static func foregroundNotificationWith(
    style: PWForegroundPushStyle,
    duration: Int,
    vibration: PWForegroundPushHapticFeedback,
    disappearedPushAnimation: PWForegroundPushDisappearedAnimation
)
```

`প্যারামিটার:`

1. `style` (`PWForegroundPushStyle`)
* বর্তমানে, শুধুমাত্র `style1` উপলব্ধ।

2. `duration` (`Int`)
* নোটিফিকেশনটি অদৃশ্য হওয়ার আগে কতক্ষণ প্রদর্শিত হবে তা নির্দিষ্ট করে (সেকেন্ডে)।

3. `vibration` (`PWForegroundPushHapticFeedback`)
* নোটিফিকেশন প্রদর্শিত হলে হ্যাপটিক ফিডব্যাক নিয়ন্ত্রণ করে। উপলব্ধ বিকল্পগুলি:

```swift
case none           // কোনো ভাইব্রেশন নেই
case light          // হালকা ভাইব্রেশন
case medium         // মাঝারি ভাইব্রেশন
case heavy          // ভারী ভাইব্রেশন
case soft           // নরম ভাইব্রেশন
case rigid          // অনমনীয় ভাইব্রেশন
case notification   // স্ট্যান্ডার্ড নোটিফিকেশন ভাইব্রেশন
```

4. `disappearedPushAnimation` (`PWForegroundPushDisappearedAnimation`)
* পুশ অদৃশ্য হওয়ার অ্যানিমেশন

```swift
case balls = 0
case regularPush
```

### ৪. `didTapForegroundPush` ডেলিগেট মেথড প্রয়োগ করা

কাস্টম ফোরগ্রাউন্ড পুশ নোটিফিকেশনে ব্যবহারকারীর ট্যাপ পরিচালনা করতে, `PWForegroundPushDelegate` প্রোটোকল মেথডটি প্রয়োগ করুন:

```swift
// ফোরগ্রাউন্ড পুশে ট্যাপ হ্যান্ডেল করুন
func didTapForegroundPush(_ userInfo: [AnyHashable : Any]) {
    print("Foreground custom push: \(userInfo)")

    // যেকোনো অ্যাকশন সম্পাদন করুন, যেমন, একটি নির্দিষ্ট স্ক্রিনে নেভিগেট করুন
    // navigateToScreen(for: userInfo)
}
```

নোট:

* ব্যবহারকারী যখন একটি কাস্টম ফোরগ্রাউন্ড পুশে ট্যাপ করে তখন এই মেথডটি কল করা হয়।
* `userInfo`-তে নোটিফিকেশনের পেলোড থাকে।
* কনফিগারেশনের পরে `Pushwoosh.ForegroundPush.delegate = self` সেট করতে ভুলবেন না।

### ৫. ফোরগ্রাউন্ড পুশ নোটিফিকেশন কাস্টমাইজ করার জন্য ঐচ্ছিক প্যারামিটার

`PushwooshForegroundPush` মডিউলটি আপনার ফোরগ্রাউন্ড পুশ নোটিফিকেশনের চেহারা এবং আচরণ কাস্টমাইজ করার জন্য বেশ কিছু ঐচ্ছিক প্যারামিটার সরবরাহ করে। এগুলি স্ট্যাটিক প্রপার্টির মাধ্যমে বিশ্বব্যাপী সেট করা যেতে পারে।

<table>
  <thead>
    <tr>
      <th style={{ width: '20%' }}>প্রপার্টি</th>
      <th style={{ width: '15%' }}>টাইপ</th>
      <th style={{ width: '45%' }}>বিবরণ</th>
      <th style={{ width: '20%' }}>ডিফল্ট</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>useLiquidView</td>
      <td>Bool</td>
      <td>iOS 26-এ লিকুইড গ্লাস ভিউ ব্যবহার করুন।</td>
      <td>false</td>
    </tr>
    <tr>
      <td>gradientColors</td>
      <td>[UIColor]?</td>
      <td>গ্রেডিয়েন্ট ব্যাকগ্রাউন্ডের জন্য রঙের ঐচ্ছিক অ্যারে।</td>
      <td>nil</td>
    </tr>
    <tr>
      <td>backgroundColor</td>
      <td>UIColor?</td>
      <td>পুশের জন্য ব্যাকগ্রাউন্ডের রঙ। যদি nil হয় এবং gradientColors সেট করা না থাকে, তাহলে ডিফল্ট গ্রেডিয়েন্ট ব্যবহৃত হয়।</td>
      <td>ডিফল্ট সিস্টেম গ্রেডিয়েন্ট</td>
    </tr>
    <tr>
      <td>usePushAnimation</td>
      <td>Bool</td>
      <td>পুশ প্রদর্শিত হওয়ার সময় অ্যানিমেট করা হবে কিনা।</td>
      <td>true</td>
    </tr>
    <tr>
      <td>titlePushColor</td>
      <td>UIColor?</td>
      <td>নোটিফিকেশন শিরোনামের টেক্সটের রঙ। nil হলে ডিফল্ট সিস্টেম সাদা রঙ ব্যবহৃত হয়।</td>
      <td>white</td>
    </tr>
    <tr>
      <td>messagePushColor</td>
      <td>UIColor?</td>
      <td>নোটিফিকেশন বার্তার টেক্সটের রঙ। nil হলে ডিফল্ট সিস্টেম সাদা রঙ ব্যবহৃত হয়।</td>
      <td>white</td>
    </tr>
    <tr>
      <td>titlePushFont</td>
      <td>UIFont?</td>
      <td>নোটিফিকেশন শিরোনামের টেক্সটের ফন্ট। nil হলে ডিফল্ট সিস্টেম ফন্ট ব্যবহৃত হয়।</td>
      <td>ডিফল্ট সিস্টেম ফন্ট</td>
    </tr>
    <tr>
      <td>messagePushFont</td>
      <td>UIFont?</td>
      <td>নোটিফিকেশন বার্তার টেক্সটের ফন্ট। nil হলে ডিফল্ট সিস্টেম ফন্ট ব্যবহৃত হয়।</td>
      <td>ডিফল্ট সিস্টেম ফন্ট</td>
    </tr>
  </tbody>
</table>

<Aside type="caution" title="গুরুত্বপূর্ণ">
- যদি `useLiquidView` ফ্ল্যাগ সক্রিয় থাকে কিন্তু ব্যবহারকারীর সিস্টেম সংস্করণ **iOS 26**-এর চেয়ে কম হয়, তাহলে এর পরিবর্তে একটি নিয়মিত `UIView`-ভিত্তিক পুশ দেখানো হবে।
- যদি আপনার প্রজেক্টটি **5.13**-এর চেয়ে কম সুইফট সংস্করণ দিয়ে কম্পাইল করা হয়, তাহলে লিকুইড গ্লাস এফেক্টটি একেবারেই উপলব্ধ হবে না — এমনকি iOS 26-এও নয়। সেক্ষেত্রে, সমস্ত ডিভাইসে এর পরিবর্তে একটি ঝাপসা `UIVisualEffectView` (`UIBlurEffect` সহ) ব্যবহার করা হবে।
</Aside>

**সারসংক্ষেপ:**
- সুইফট 5.13+ + iOS 26 → লিকুইড গ্লাস
- সুইফট 5.13+ + iOS < 26 → স্ট্যান্ডার্ড UIView
- সুইফট < 5.13 → সর্বদা ঝাপসা ভিউ (লিকুইড গ্লাস সমর্থন নেই)


**উদাহরণ ব্যবহার:**

```swift
Pushwoosh.ForegroundPush.useLiquidView = true
Pushwoosh.ForegroundPush.gradientColors = [.red, .orange, .yellow]
Pushwoosh.ForegroundPush.titlePushColor = .red
Pushwoosh.ForegroundPush.messagePushColor = .green
Pushwoosh.ForegroundPush.backgroundColor = .black
Pushwoosh.ForegroundPush.titlePushFont = .boldSystemFont(ofSize: 22)
Pushwoosh.ForegroundPush.messagePushFont = .italicSystemFont(ofSize: 15)
Pushwoosh.ForegroundPush.usePushAnimation = false
```

### ৬. ফোরগ্রাউন্ড পুশের উদাহরণ

এই উদাহরণটি দেখায় কিভাবে শিরোনাম, বার্তা, কার্ড এবং GIF অ্যানিমেশন সহ একটি কাস্টম ফোরগ্রাউন্ড পুশ নোটিফিকেশন প্রদর্শন করা যায়।

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-5.webm" title="উদাহরণ" autoplay loop muted playsinline />
  <figcaption>অ্যানিমেটেড লিকুইড গ্লাস ভিউ সহ Pushwoosh ফোরগ্রাউন্ড পুশ</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-1.webm" title="উদাহরণ" autoplay loop muted playsinline />
  <figcaption>gif সংযুক্তি সহ Pushwoosh ফোরগ্রাউন্ড পুশ</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-2.webm" title="উদাহরণ" autoplay loop muted playsinline />
  <figcaption>কার্ড ইমেজ সহ Pushwoosh ফোরগ্রাউন্ড পুশ</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-3.webm" title="উদাহরণ" autoplay loop muted playsinline />
  <figcaption>একটি কাস্টম গ্রেডিয়েন্ট, এবং কাস্টম শিরোনাম এবং বার্তার রঙ সহ Pushwoosh ফোরগ্রাউন্ড পুশ</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-4.webm" title="উদাহরণ" autoplay loop muted playsinline />
  <figcaption>কাস্টম ব্যাকগ্রাউন্ড, শিরোনাম এবং বার্তার ফন্ট, এবং কোনো অ্যানিমেশন ছাড়া Pushwoosh ফোরগ্রাউন্ড পুশ</figcaption>
</figure>

এটাই সব। আপনি সফলভাবে Pushwoosh-এর সাথে iOS-এ কাস্টম ফোরগ্রাউন্ড পুশ নোটিফিকেশন কনফিগার করেছেন।