تخطَّ إلى المحتوى

iOS (Swift)

التثبيت

في Xcode: File ← Add Package Dependencies ← https://github.com/heysada/sada-ios، ثم أضف مكتبة HeysadaSanad إلى هدف تطبيقك.

حزمة Swift واحدة تضم كل حزمنا، فلها إصدار واحد لكل المنتجات: تُحدَّث معاً. وكل مكتبة تربط الملف الثنائي نفسه HeysadaKit، فـالتطبيق يحمل شيفرة كل المنتجات أياً كانت المكتبات التي يستعملها (تطبيق iOS لا يحمل إلا بيئة Kotlin واحدة، فتشترك المنتجات في إطار واحد).

شرح الاستخدام أدناه بالإنجليزية، كما يظهر في سجل الحزمة، والشيفرة نفسها في كل لغة.

In-app support as a messenger, for SwiftUI and UIKit apps: your team’s welcome and reply time, the user’s conversations live, a thread with images, typing and “Seen”, your help articles, and the contact form with a screenshot of the screen the user was on. It presents the same Compose screens as Android, from the Kotlin Multiplatform SDK, drawn from the app’s design; Arabic is right to left.

import HeysadaSanad

@main
struct WalletApp: App {
    init() {
        Sanad.configure(appKey: "pk_…", apiUrl: "https://support.example.com")
    }
    var body: some Scene {
        WindowGroup {
            ContentView()
                .overlay(alignment: .bottomTrailing) { SanadLauncher().padding() }
        }
    }
}

// or your own button:
Button("Help") { Sanad.open() }
  • Sanad.open() shows the home; openContact() the contact form; openConversation(id) one conversation (from a push about a reply, say); openArticle(id) one help article.
  • SanadLauncher is a round button with the unread badge; SanadUnread is the same count, live, for a badge of your own.
  • Mark what must never leave the device with Sanad.mask(view). Secure text fields and web views are blacked out of the screenshot too, before the user sees it.
  • userToken (the signed-in user’s token from the platform’s identify) is not yet accepted: until the service runs on the end-user token verifier, a sent token is refused; leave it out.
  • It never opens itself and never throws into your app. The screenshot is one still image of the key window, at most 2× and 4096 px on a side, taken before anything is drawn; it lives in memory only. What waits offline is text only, at most 5 messages, for 3 days.
  • Requires iOS 15. The photo picker is the system’s (PHPicker): no permission prompt.

Ways in, and opening from a failure

Sanad.configure(
    appKey: "pk_…", apiUrl: "https://support.example.com",
    invocations: SanadInvocations(shake: true, screenshot: true, launcher: true)
)

Sanad.openContact(
    topic: "payment_failed",
    attributes: ["order_id": order.id, "error_code": code, "amount": 12.5],
    message: "My payment didn't go through"
)
  • Shake uses CoreMotion’s accelerometer while the app is active. It opens a chooser, or the form straight away with shakeOpensContact: true.
  • Screenshot: after userDidTakeScreenshotNotification a prompt that doesn’t block the screen offers help, and it opens the form with the SDK’s own masked capture. The system’s image is never read.
  • Launcher floats over the key window. The user can drag it, and when they let go it snaps to the nearer side edge (leading in Arabic). It shows the unread badge. Use Sanad.hideLauncher()/showLauncher(). SanadLauncher stays for placing it yourself.
  • The team sees the topic and attributes with the conversation. Keys are snake_case, values are flat (String, a number, Bool), and at most 20 are sent.