# iOS कस्टम फोरग्राउंड पुश नोटिफिकेशन

संस्करण 6.10.0 से, आप `PushwooshForegroundPush` मॉड्यूल को एकीकृत कर सकते हैं ताकि नेटिव iOS सिस्टम अलर्ट अक्षम होने पर फोरग्राउंड पुश नोटिफिकेशन को कस्टमाइज़ किया जा सके।

### 1. नेटिव फोरग्राउंड पुश अलर्ट अक्षम करें

अपने `Info.plist` में `Pushwoosh_SHOW_ALERT = false` जोड़ना।

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

### 2. `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
```

### 3. 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
```

### 4. `didTapForegroundPush` डेलीगेट मेथड को लागू करना

कस्टम फोरग्राउंड पुश नोटिफिकेशन पर उपयोगकर्ता के टैप को संभालने के लिए, `PWForegroundPushDelegate` प्रोटोकॉल मेथड को लागू करें:

```swift
// Handle tap on foreground push
func didTapForegroundPush(_ userInfo: [AnyHashable : Any]) {
    print("Foreground custom push: \(userInfo)")

    // Perform any action, e.g., navigate to a specific screen
    // navigateToScreen(for: userInfo)
}
```

नोट्स:

* यह मेथड तब कॉल किया जाता है जब उपयोगकर्ता कस्टम फोरग्राउंड पुश पर टैप करता है।
* `userInfo` में नोटिफिकेशन का पेलोड होता है।
* कॉन्फ़िगरेशन के बाद `Pushwoosh.ForegroundPush.delegate = self` सेट करना सुनिश्चित करें।

### 5. फोरग्राउंड पुश नोटिफिकेशन को कस्टमाइज़ करने के लिए वैकल्पिक पैरामीटर्स

`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>

**सारांश:**
- Swift 5.13+ + iOS 26 → लिक्विड ग्लास
- Swift 5.13+ + iOS < 26 → मानक UIView
- Swift < 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
```

### 6. फोरग्राउंड पुश का उदाहरण

यह उदाहरण `title`, `message`, `cards`, और `GIF animation` के साथ एक कस्टम फोरग्राउंड पुश नोटिफिकेशन प्रदर्शित करने का तरीका दिखाता है।

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-5.webm" title="Example" autoplay loop muted playsinline />
  <figcaption>एनिमेटेड लिक्विड ग्लास व्यू के साथ पुशवूश फोरग्राउंड पुश</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-1.webm" title="Example" autoplay loop muted playsinline />
  <figcaption>gif अटैचमेंट के साथ पुशवूश फोरग्राउंड पुश</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-2.webm" title="Example" autoplay loop muted playsinline />
  <figcaption>कार्ड इमेज के साथ पुशवूश फोरग्राउंड पुश</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-3.webm" title="Example" autoplay loop muted playsinline />
  <figcaption>एक कस्टम ग्रेडिएंट, और कस्टम शीर्षक और संदेश रंगों के साथ पुशवूश फोरग्राउंड पुश</figcaption>
</figure>

<figure style={{ textAlign: "center" }}>
  <video src="/ios-foreground-custom-4.webm" title="Example" autoplay loop muted playsinline />
  <figcaption>कस्टम बैकग्राउंड, शीर्षक और संदेश फ़ॉन्ट्स, और बिना एनिमेशन के पुशवूश फोरग्राउंड पुश</figcaption>
</figure>

बस इतना ही। आपने पुशवूश के साथ iOS में कस्टम फोरग्राउंड पुश नोटिफिकेशन को सफलतापूर्वक कॉन्फ़िगर कर लिया है।