<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eren Ali Koca on Medium]]></title>
        <description><![CDATA[Stories by Eren Ali Koca on Medium]]></description>
        <link>https://medium.com/@erenali?source=rss-30a543848994------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1-XJSY76V8m8xydFrwEimw.png</url>
            <title>Stories by Eren Ali Koca on Medium</title>
            <link>https://medium.com/@erenali?source=rss-30a543848994------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 12:14:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erenali/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[iOS UI Freezing: Mastering Main Thread Debugging Like a Pro]]></title>
            <link>https://medium.com/icommunity/ios-ui-freezing-mastering-main-thread-debugging-like-a-pro-6a55955e7c6d?source=rss-30a543848994------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a55955e7c6d</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Eren Ali Koca]]></dc:creator>
            <pubDate>Fri, 26 Dec 2025 19:16:42 GMT</pubDate>
            <atom:updated>2025-12-26T19:16:42.934Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚨 iOS UI Freezing: Mastering Main Thread Debugging Like a Pro</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KwR0vof296jDMEqTypABQ.png" /></figure><blockquote>“If your UI freezes, your users don’t care why — they just leave.”</blockquote><p>If this has ever happened to you in production — you’re not alone.</p><p>UI freezing is one of the most subtle yet destructive performance issues in iOS applications. Unlike crashes, freezes don’t leave clear stack traces, logs, or error messages. The app technically <em>works</em> — it just feels broken.</p><p>In this article, we’ll explore:</p><ul><li>What <strong>UI freezing</strong> really is</li><li>Why the <strong>Main Thread</strong> is sacred</li><li>The most common real-world causes</li><li>How to <strong>debug freezes professionally</strong></li><li>Best practices to prevent them entirely</li></ul><p>This is not an introductory article. It’s written for developers who want to <strong>think like the system</strong>.</p><h3>🧠 Understanding the Main Thread (RunLoop Mental Model)</h3><p>Every iOS app has one <strong>Main Thread</strong>, responsible for:</p><ul><li>Rendering UI</li><li>Handling user interactions</li><li>Running animations</li><li>Processing touch events</li></ul><p>At the heart of it lies the <strong>RunLoop</strong> — an event-processing loop that must remain responsive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Bxgpr653f8ljXnHSYlepw.png" /></figure><p>If the Main Thread is blocked for <strong>more than ~16ms</strong>, frames drop.</p><p>Block it for <strong>100ms+</strong>, users perceive lag.</p><p>Block it for <strong>seconds</strong>, the app feels frozen.</p><p><strong>UIKit is not thread-safe.</strong></p><p>Anything UI-related must happen on the Main Thread — but <strong>not everything should</strong>.</p><h3>❌ The #1 Cause: Heavy Work on the Main Thread</h3><p>The most common mistake is <em>not</em> forgetting to use background threads — it’s <strong>underestimating how expensive work really is</strong>. Most real-world freezes come from code that looks completely harmless.</p><h3>Typical offenders:</h3><ul><li>JSON parsing</li><li>Image decoding</li><li>Core Data fetches</li><li>Synchronous network calls</li><li>File I/O</li><li>Date formatting in loops</li><li>Auto Layout recalculations</li><li>Large table/collection view reloads</li></ul><pre>// ❌ Dangerous<br>DispatchQueue.main.async {<br>    let data = try! Data(contentsOf: url)<br>    let image = UIImage(data: data)<br>    imageView.image = image<br>}</pre><p>This code <em>looks</em> innocent. It isn’t.</p><h3>⚠️ The Silent Killer: Synchronous APIs</h3><p>Synchronous APIs on the Main Thread are UI-freeze landmines.</p><p>Examples:</p><ul><li>Data(contentsOf:)</li><li>sleep()</li><li>dispatchSemaphore.wait()</li><li>URLSession.shared.sync</li><li>performAndWait (Core Data)</li><li>NSManagedObjectContext.performAndWait</li></ul><pre>// ❌ UI Freeze guaranteed<br>let semaphore = DispatchSemaphore(value: 0)<br>api.fetch {<br>    semaphore.signal()<br>}<br>semaphore.wait()</pre><p>Your UI is now held hostage.</p><h3>🔬 Debugging UI Freezes Like a Senior Engineer</h3><h3>1️⃣ Xcode Main Thread Checker</h3><p>Enable it:</p><p>Edit Scheme → Diagnostics → Main Thread Checker</p><p>It catches:</p><ul><li>UI access from background threads</li><li>Some common thread misuse patterns</li></ul><p>Useful, but <strong>not sufficient</strong>.</p><h3>2️⃣ Instruments — Time Profiler (Your Best Friend)</h3><p>Steps:</p><ol><li>Product → Profile</li><li>Choose <strong>Time Profiler</strong></li><li>Record while reproducing the freeze</li><li>Filter by <strong>Main Thread</strong></li><li>Look for long-running methods</li></ol><p>🚨 Red flags:</p><ul><li>Long purple bars</li><li>objc_msgSend</li><li>JSON decoding</li><li>Image decoding</li><li>Auto Layout passes</li></ul><h3>3️⃣ Symbolic Breakpoints for Freeze Detection</h3><p>Add symbolic breakpoints:</p><ul><li>UIView layoutSubviews</li><li>-[NSLayoutConstraint _updateLayoutEngine]</li><li>-[CALayer layoutSublayers]</li></ul><p>If these are hit repeatedly in loops — you’ve found your freeze.</p><h3>🧵 GCD &amp; Concurrency — The Right Way</h3><p>Golden rule:</p><blockquote><strong><em>Compute in background, update UI on Main.</em></strong></blockquote><pre>DispatchQueue.global(qos: .userInitiated).async {<br>    let image = heavyImageProcessing()<br><br>    DispatchQueue.main.async {<br>        imageView.image = image<br>    }<br>}</pre><p>Prefer:</p><ul><li>async/await</li><li>Structured concurrency</li><li>Task {} with @MainActor,</li></ul><pre>Task {<br>    let image = await loadImage()<br>    await MainActor.run {<br>        imageView.image = image<br>    }<br>}</pre><h3>🧨 Auto Layout: The Hidden Performance Trap</h3><p>Auto Layout is powerful — and expensive.</p><p>Common mistakes:</p><ul><li>Calling layoutIfNeeded() repeatedly</li><li>Animating constraints inside loops</li><li>Updating constraints every frame</li><li>Deep view hierarchies</li><li>Triggering layout passes inside scroll or animation callbacks</li></ul><p>Tips:</p><ul><li>Batch constraint updates</li><li>Avoid unnecessary setNeedsLayout</li><li>Prefer fixed layouts when possible</li></ul><h3>🧪 Real-World Freeze Debugging Checklist</h3><p>When UI freezes:</p><ul><li>❓ Is the Main Thread blocked?</li><li>❓ Any synchronous APIs?</li><li>❓ Heavy parsing or decoding?</li><li>❓ Auto Layout loops?</li><li>❓ Table/Collection reload storms?</li><li>❓ Core Data on Main Thread?</li></ul><p>If yes — you know where to dig.</p><h3>🛡️ Preventing Freezes Before They Exist</h3><p>Best practices:</p><ul><li>Never block the Main Thread</li><li>Assume everything is expensive</li><li>Measure, don’t guess</li><li>Profile early</li><li>Treat UI performance as a feature</li></ul><h3>🧠 Final Thought</h3><p>UI freezing is not a bug — it’s a <strong>design failure</strong>.</p><p>Users forgive missing features.</p><p>They do not forgive lag.</p><p>If you master the Main Thread, you master iOS performance.</p><blockquote><em>If you’ve ever chased a UI freeze that disappeared the moment you attached the debugger, <br>you already know how deceptive these issues can be. <br>Treat performance problems with the same respect as correctness — they define how your app feels, not just how it works.</em></blockquote><p>#iOS #Swift #Mobile Development #Performance #Debugging #UIKit</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a55955e7c6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/icommunity/ios-ui-freezing-mastering-main-thread-debugging-like-a-pro-6a55955e7c6d">iOS UI Freezing: Mastering Main Thread Debugging Like a Pro</a> was originally published in <a href="https://medium.com/icommunity">iCommunity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Screenshot & Screen Recording Protection in UIKit: A Production‑Ready Pattern]]></title>
            <link>https://medium.com/icommunity/screenshot-screen-recording-protection-in-uikit-a-production-ready-pattern-39616f444826?source=rss-30a543848994------2</link>
            <guid isPermaLink="false">https://medium.com/p/39616f444826</guid>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Eren Ali Koca]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 15:14:11 GMT</pubDate>
            <atom:updated>2025-08-13T15:14:11.657Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oc81b7qEknUs_jpoi9dAOA.png" /></figure><p>Protecting sensitive content from screenshots and screen recordings is a frequent requirement for finance, health, and messaging apps. In this guide, we’ll build a robust UIKit pattern that:</p><ul><li>Forces system captures (screenshots and recordings) saved to Photos to be completely black</li><li>Optionally shows a short-lived, branded privacy overlay inside your app</li><li>Uses only public APIs and works reliably in production</li></ul><p><strong>Important notes:</strong></p><ul><li>This technique works on real devices. It will not work in the Xcode Simulator.</li><li>With this setup, screenshots and screen recordings saved to Photos (gallery) are fully black.</li></ul><p><strong>What we’ll build</strong></p><ul><li>A secure window that renders through a hidden secure text field, causing the OS capture pipeline to record black output.</li><li>An optional in‑app overlay (your own design) shown briefly when a screenshot is taken.</li><li>A feature toggle via `<em>UserDefaults</em>` so you can enable/disable easily.</li></ul><p><strong>How it works</strong><br>We leverage a system behavior: content inside a secure text field (`UITextField` with `isSecureTextEntry = true`) is protected from system capture. By reparenting the app window’s layer under a secure text field’s layer, the OS “sees” only secure content, producing black screenshots and screen recordings in Photos. Inside the app, you can show a friendly overlay view so users aren’t confused.</p><p>You’ll design your overlay (`PrivacyProtectionView`) as you like; this article focuses on the three key integration points.</p><h4>1) Secure the window (UIWindow+Secure.swift)</h4><p>This extension:</p><ul><li>Checks a `<em>privacyProtectionEnabled</em>` toggle (so you can control rollout)</li><li>Wraps the window’s layer under a secure text field’s layer</li><li>Sets your overlay view into the text field’s `<em>leftView</em>` so the user sees a nice privacy screen inside the app</li></ul><pre>import UIKit<br><br>extension UIWindow {<br>    func makeSecure() {<br>        if !UserDefaults.standard.bool(forKey: &quot;privacyProtectionEnabled&quot;) {<br>            return<br>        }<br>        let field = UITextField()<br>        let view = PrivacyProtectionView(frame: self.bounds)<br>        field.isSecureTextEntry = true<br>        self.addSubview(field)<br>        self.layer.superlayer?.addSublayer(field.layer)<br>        field.layer.sublayers?.last!.addSublayer(self.layer)<br>        field.leftView = view<br>        field.leftViewMode = .always<br>    }<br>}</pre><p>Why this works:</p><ul><li>The window’s contents are rendered under a secure text field layer chain. The OS capture pipeline treats it as protected content, so Photos saves black frames.</li></ul><h4>2) Attach at the right time (SceneDelegate.swift)</h4><p>Attach security right after the window becomes visible. Timing matters: the window’s `<em>layer.superlayer</em>` must exist; deferring with `<em>DispatchQueue.main.async</em>` ensures stability across iOS versions.</p><pre>func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {<br>    guard let windowScene = scene as? UIWindowScene else { return }<br>    let window = UIWindow(windowScene: windowScene)<br>    self.window = window<br>    window.rootViewController = ViewController()<br>    <br>    window.makeKeyAndVisible()<br><br>    // Window layer hierarchy is ready — now secure it<br>    if UserDefaults.standard.bool(forKey: &quot;privacyProtectionEnabled&quot;) {<br>        DispatchQueue.main.async { [weak window] in<br>            window?.makeSecure()<br>        }<br>    }<br>}</pre><h4>3) A friendly in‑app signal on screenshots (AppDelegate.swift)</h4><p>Handle screenshot notifications and show your overlay briefly (e.g., 2 seconds). This is purely UX — Photos output is already black thanks to the secure window.</p><pre>func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>    // Enable for testing; gate this with your own logic in production<br>    UserDefaults.standard.set(true, forKey: &quot;privacyProtectionEnabled&quot;)<br><br>    NotificationCenter.default.addObserver(<br>        self,<br>        selector: #selector(screenshotDetected),<br>        name: UIApplication.userDidTakeScreenshotNotification,<br>        object: nil<br>    )<br>    return true<br>}<br><br>@objc private func screenshotDetected() {<br>    let enabled = UserDefaults.standard.bool(forKey: &quot;privacyProtectionEnabled&quot;)<br>    if enabled {<br>        DispatchQueue.main.async { self.showPrivacyScreen() }<br>    }<br>}<br><br>private func showPrivacyScreen() {<br>    guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,<br>          let window = windowScene.windows.first else { return }<br>    let privacyView = PrivacyProtectionView(frame: window.bounds)<br>    window.addSubview(privacyView)<br>    DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {<br>        privacyView.removeFromSuperview()<br>    }<br>}</pre><p>Tip:</p><ul><li>Implement `<em>PrivacyProtectionView</em>` as a lightweight, brand‑aligned overlay. Keep it fast to render.</li></ul><h4>Testing and expected results</h4><p><strong>Real device only:</strong> This protection does not work on the Xcode Simulator. Test on iPhone hardware.</p><blockquote><strong>Screenshot test:</strong></blockquote><ul><li>Take a screenshot while your app is on-screen.</li><li>In Photos (gallery), the saved image will be completely black.</li><li>Inside your app, the privacy overlay briefly appears, then disappears.</li></ul><blockquote><strong>Screen recording test:</strong></blockquote><ul><li>Start a recording from Control Center, use the app, then stop.</li><li>In Photos, the recorded video will be completely black.</li></ul><blockquote><strong>Rotation and size classes:</strong></blockquote><ul><li>Ensure your overlay view is responsive.</li></ul><blockquote><strong>Multi‑window (iPad, macCatalyst):</strong></blockquote><ul><li>If you support multiple scenes/windows, secure each window after it’s visible.</li></ul><h4>Common pitfalls</h4><blockquote><strong>Calling `makeSecure()` too early:</strong></blockquote><ul><li>If the window’s layer isn’t attached yet, reparenting may fail silently. Fix: defer with `DispatchQueue.main.async` after `makeKeyAndVisible()`.</li></ul><blockquote><strong>Heavy overlays:</strong></blockquote><ul><li>Overly complex overlays can cause jank on older devices. Keep it minimal (icon + short message).</li></ul><blockquote><strong>Simulator expectations:</strong></blockquote><ul><li>Don’t expect black captures on Simulator — this is a device‑only behavior.</li></ul><h4>Production notes</h4><ul><li>This pattern uses public APIs and is widely used to protect sensitive content.</li><li>Provide a subtle, informative overlay so users understand what happened when they take a screenshot.</li><li>Consider a settings toggle or FAQ entry explaining why the app protects content.</li></ul><h4>Wrap‑up</h4><p>With a small amount of UIKit code, you can robustly protect your app’s content: screenshots and screen recordings saved to Photos will be solid black, while your users see a polished in‑app overlay for clarity. The core logic lives in:<br>- `UIWindow+Secure.swift`: secure layer reparenting<br>- `SceneDelegate.swift`: correct timing of attachment<br>- `AppDelegate.swift`: optional screenshot overlay</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGtW9K108HF7PlO7tMzUYg.png" /><figcaption><em>PrivacyProtectionView.swift</em></figcaption></figure><p>#iOS #UIKit #Swift #Security #Privacy #MobileApps</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39616f444826" width="1" height="1" alt=""><hr><p><a href="https://medium.com/icommunity/screenshot-screen-recording-protection-in-uikit-a-production-ready-pattern-39616f444826">Screenshot &amp; Screen Recording Protection in UIKit: A Production‑Ready Pattern</a> was originally published in <a href="https://medium.com/icommunity">iCommunity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Dark Mode in UIKit: A Comprehensive Guide]]></title>
            <link>https://medium.com/icommunity/implementing-dark-mode-in-uikit-a-comprehensive-guide-a96919f9873e?source=rss-30a543848994------2</link>
            <guid isPermaLink="false">https://medium.com/p/a96919f9873e</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[themes]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Eren Ali Koca]]></dc:creator>
            <pubDate>Tue, 06 May 2025 18:31:28 GMT</pubDate>
            <atom:updated>2025-05-06T18:31:28.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hasZaij8-3w_yr5vKiblDQ.png" /></figure><h3><strong>Introduction</strong></h3><p>Since iOS 13, Dark Mode has become a standard feature that users expect in modern applications. Not only does it provide a visually appealing alternative interface, but it also reduces eye strain in low-light environments and can help save battery life on OLED displays.</p><p>While SwiftUI offers built-in support for Dark Mode, many developers still work with UIKit for various reasons. This article will guide you through implementing a robust Dark Mode solution in your UIKit-based iOS applications.</p><h3>Understanding UIKit’s Dark Mode Architecture</h3><p>Before we dive into implementation, it’s important to understand how Dark Mode works in UIKit. At its core, Dark Mode in iOS relies on two key concepts:</p><ol><li><strong>Color Semantics</strong>: Instead of using fixed colors, UIKit provides semantic colors that automatically adapt based on the user’s appearance preferences.</li><li><strong>Trait Collections</strong>: These objects contain information about the environment in which your app is running, including the preferred user interface style (light or dark).</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FtXL4FHPSnVJ0A%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcDByOTkxMnI0NXVjY3UwMWtkZTVld3l1Zzc5ZHZwdWJxY3ZqY3M3NiZlcD12MV9naWZzX3RyZW5kaW5nJmN0PWc%2FtXL4FHPSnVJ0A%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExM2RzMzQzeDN5bmVzMXRlenJ3YWMzb29hendicjNsam1pM3o1aXlrNyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FtXL4FHPSnVJ0A%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="291" frameborder="0" scrolling="no"><a href="https://medium.com/media/d62c144b9c0fbe15e269736e64595cb3/href">https://medium.com/media/d62c144b9c0fbe15e269736e64595cb3/href</a></iframe><h3>Setting Up Your Project for Dark Mode</h3><h4>Step 1: Configure Your Info.plist</h4><p>First, ensure your app is ready to support Dark Mode by adding the UIUserInterfaceStyle key to your Info.plist:</p><pre>&lt;key&gt;UIUserInterfaceStyle&lt;/key&gt;<br>&lt;string&gt;Light&lt;/string&gt;</pre><p>You can set this to Light, Dark, or remove it entirely to respect the user&#39;s system setting.</p><h4>Step 2: Use Semantic Colors</h4><p>Replace hardcoded colors with semantic colors that automatically adapt to the current appearance:</p><pre>// Instead of this:<br>view.backgroundColor = UIColor.white<br>label.textColor = UIColor.black<br><br>// Do this:<br>view.backgroundColor = UIColor.systemBackground<br>label.textColor = UIColor.label</pre><p>Here’s a reference of commonly used semantic colors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bNpQnU3R5pXI4iqClUwFug.png" /></figure><h4>Responding to Appearance Changes</h4><p>When the user switches between light and dark mode, your app needs to update its interface accordingly.</p><p><strong>Override traitCollectionDidChange</strong></p><pre>override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {<br>    super.traitCollectionDidChange(previousTraitCollection)<br>    <br>    if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {<br>        updateAppearance()<br>    }<br>}<br><br>private func updateAppearance() {<br>    // Update any custom views or elements that need specific handling<br>    customView.layer.borderColor = UIColor.label.cgColor<br>    <br>    // Refresh table or collection views if needed<br>    tableView.reloadData()<br>}</pre><h4>Testing Dark Mode</h4><p>To effectively test Dark Mode:</p><ol><li><strong>Simulator Testing</strong>: Use the Environment Overrides feature (Debug → Environment Overrides → Interface Style)</li><li><strong>Real Device Testing</strong>: Toggle Dark Mode in device settings</li><li><strong>Dynamic Testing</strong>: Test transitions between modes</li></ol><h4>Programmatically Setting App Appearance</h4><p>You can override the system appearance for your app:</p><pre>// Force light mode<br>window?.overrideUserInterfaceStyle = .light<br><br>// Force dark mode<br>window?.overrideUserInterfaceStyle = .dark<br><br>// Respect system setting<br>window?.overrideUserInterfaceStyle = .unspecified</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*Ipir-ucgGYj_x_SuzqCciw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*UX7--BxnflPaBzTpWX02kA.png" /><figcaption>App Theme</figcaption></figure><p>For individual view controllers:</p><pre>viewController.overrideUserInterfaceStyle = .dark</pre><h4>Advanced: Creating a Theme Manager</h4><p>For more complex apps, consider implementing a theme manager:</p><pre>class ThemeManager {<br>    static let shared = ThemeManager()<br>    <br>    enum Theme {<br>        case system<br>        case light<br>        case dark<br>    }<br>    <br>    var currentTheme: Theme = .system {<br>        didSet {<br>            applyTheme()<br>        }<br>    }<br>    <br>    private func applyTheme() {<br>        let windows = UIApplication.shared.windows<br>        <br>        switch currentTheme {<br>        case .light:<br>            windows.forEach { $0.overrideUserInterfaceStyle = .light }<br>        case .dark:<br>            windows.forEach { $0.overrideUserInterfaceStyle = .dark }<br>        case .system:<br>            windows.forEach { $0.overrideUserInterfaceStyle = .unspecified }<br>        }<br>    }<br>}<br><br>// Usage<br>ThemeManager.shared.currentTheme = .dark</pre><h4>Performance Considerations</h4><ul><li><strong>Avoid Expensive Operations</strong>: Don’t perform heavy layout or data processing during appearance transitions</li><li><strong>Cache Resources</strong>: Pre-compute resources for both appearance modes when possible</li><li><strong>Minimize Redraws</strong>: Only update what’s necessary when the appearance changes</li></ul><h4><strong>Third-party Libraries</strong></h4><p>Check if your third-party UI libraries support Dark Mode. If not, you might need to apply custom styling or look for alternatives.</p><h4>Conclusion</h4><p>Implementing Dark Mode in UIKit is a combination of using the right system colors, handling appearance changes gracefully, and thinking proactively about your application’s visual elements. When done correctly, it not only improves the user experience but can also make your app feel more modern and considerate of user preferences.</p><p>Remember that Dark Mode isn’t just about inverting colors — it’s about creating a comfortable, readable interface that respects the environment in which your users are operating. Take the time to test thoroughly and ensure that every aspect of your interface looks great in both light and dark appearances.</p><p>By following the strategies outlined in this article, you’ll be well on your way to creating a UIKit application that seamlessly transitions between light and dark modes, delighting your users in the process.</p><h4>Resources</h4><ul><li><a href="https://developer.apple.com/design/human-interface-guidelines/dark-mode">Dark Mode | Apple Developer Documentation</a></li><li><a href="https://developer.apple.com/videos/play/wwdc2019/214/">Implementing Dark Mode on iOS - WWDC19 - Videos - Apple Developer</a></li><li><a href="https://developer.apple.com/documentation/uikit">UIKit | Apple Developer Documentation</a></li></ul><p>Thanks for reading, and here’s to cleaner, more consistent Swift code!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FUQaRUOLveyjNC%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbHhwNTh2MTMxbGN1OGF6cjB4c3ExajA0dTNsZWkzbjRrZ2E1eG5ldyZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FUQaRUOLveyjNC%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdWtxaGJlbDQ1YTBxNnBhM25rMml2MGFoMG02aHBvNmE3bzg5Y2l0NiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FUQaRUOLveyjNC%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="183" frameborder="0" scrolling="no"><a href="https://medium.com/media/dae66d7ab93e38be94aa778916c6cc01/href">https://medium.com/media/dae66d7ab93e38be94aa778916c6cc01/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a96919f9873e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/icommunity/implementing-dark-mode-in-uikit-a-comprehensive-guide-a96919f9873e">Implementing Dark Mode in UIKit: A Comprehensive Guide</a> was originally published in <a href="https://medium.com/icommunity">iCommunity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Swift’te Kullanıcı Otomatik Hesap Girişi]]></title>
            <link>https://erenali.medium.com/ios-swiftte-kullan%C4%B1c%C4%B1-otomatik-hesap-giri%C5%9Fi-3acc19e8a49d?source=rss-30a543848994------2</link>
            <guid isPermaLink="false">https://medium.com/p/3acc19e8a49d</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Eren Ali Koca]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 18:19:56 GMT</pubDate>
            <atom:updated>2025-01-15T18:19:56.917Z</atom:updated>
            <content:encoded><![CDATA[<p>Sevgili Medium Okuyucuları,</p><p>“iOS Swift uygulamalarınızda kullanıcı deneyimini iyileştirmek ve oturum açma işlemlerini otomatikleştirmek mi istiyorsunuz? Bu makalede, kullanıcıların çıkış yapmadığı sürece otomatik olarak hesaplarına giriş yapmalarını sağlamak için Swift kodunu nasıl kullanacağınızı adım adım anlatacağım.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*qW395KARLqdYJuHq6XvYrA.png" /></figure><p><strong>1- Current User ‘ ı alma işlemi:</strong></p><blockquote>Firebase entegreli projeniz için:</blockquote><pre>let currentUser = Auth.auth().currentUser</pre><blockquote>Parse entegreli projeniz için:</blockquote><pre>let currentUser = PFUser.current()</pre><p><strong>2- “SceneDelegate.swift” dosyasını düzenleme:</strong></p><blockquote>Firebase entegreli projeniz için:</blockquote><pre>func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {<br>        <br>    //Halihazırdaki fonksiyonunuza eklenecek kod bloğu<br><br>       //Mevcut kullanıcıyı alma<br>        let currentUser = Auth.auth().currentUser<br><br>       //Current User mevcutsa <br>        if currentUser != nil {<br>            let board = UIStoryboard(name: &quot;Main&quot;, bundle: nil)<br>            let tabBar = board.instantiateViewController(withIdentifier: &quot;tabBar&quot;) as! UITabBarController<br>            <br>//Tab bar kullandığımızdan dolayı belirlediğimiz Tab Bar identifierı yazdık.<br><br>            window?.rootViewController = tabBar<br>        }<br>        guard let _ = (scene as? UIWindowScene) else { return }<br>    }</pre><blockquote>Parse entegreli projeniz için:</blockquote><pre>func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {<br>    <br>//Halihazırdaki fonksiyonunuza eklenecek kod bloğu<br><br>       //Mevcut kullanıcıyı alma<br>        let currentUser = PFUser.current()<br><br>//Current User mevcutsa<br>        if currentUser != nil {<br>            let board = UIStoryboard(name: &quot;Main&quot;, bundle: nil)<br>            let navigationController = board.instantiateViewController(withIdentifier: &quot;navigationController&quot;)<br><br>//Navigation Controller kullandığımızdan dolayı belirlediğimiz Navigation Controller identifierı yazdık.<br>           <br> window?.rootViewController = navigationController<br>            <br>        }<br>        guard let _ = (scene as? UIWindowScene) else { return }<br>    }</pre><p>Current User mevcutsa Giriş ekranımızı Log In sayfasından Feed’ e (Tab Bar Controller , Navigation Controller vb.) yönlendiriyoruz.</p><p><strong>3- Log Out işlemi:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*CdhvFqKvbBGTefCvfnCPyg.png" /></figure><blockquote>Firebase entegreli projeniz için:</blockquote><pre>@IBAction func logoutClicked(_ sender: Any) {<br>        do{<br><br>//Mevcut kullanıcı çıkış işlemi<br>            try Auth.auth().signOut()<br>            self.performSegue(withIdentifier: &quot;toViewController&quot;, sender: nil)<br>        }catch{<br>            print(error)<br>        }<br>    }</pre><p>Kullanıcı çıkışı yapılır , segue gerçekleştirilir.</p><blockquote>Parse entegreli projeniz için:</blockquote><pre> @objc func logoutButtonClicked() {<br><br>//Mevcut kullanıcı çıkış işlemi<br>        PFUser.logOutInBackground() { (error) in<br>            if error != nil {<br>                self.makeAlert(titleInput: &quot;Error&quot;, messageInput: error?.localizedDescription ?? &quot;Error&quot;)<br>            }else {<br>                self.performSegue(withIdentifier: &quot;toSignUpVC&quot;, sender: nil)<br>            }<br>        }<br>    }</pre><p>Kullanıcı çıkışı yapılır , segue gerçekleştirilir.</p><p>Böylece çıkış yapmadığımız takdirde otomatik kullanıcı girişini projemize uygulamış olduk.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3acc19e8a49d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OneSignal kullanarak Swift uygulamanız için anlık bildirim ayarlama]]></title>
            <link>https://erenali.medium.com/onesignal-kullanarak-swift-uygulaman%C4%B1z-i%C3%A7in-anl%C4%B1k-bildirim-ayarlama-352d836a174a?source=rss-30a543848994------2</link>
            <guid isPermaLink="false">https://medium.com/p/352d836a174a</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[notification-service]]></category>
            <category><![CDATA[onesignal]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Eren Ali Koca]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 10:51:57 GMT</pubDate>
            <atom:updated>2025-01-11T10:54:22.237Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*WJlOwp7kKhbhGPTeM1Zs6g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*V8YQaiqcoYPbbA9etFLfhQ.jpeg" /><figcaption>Bildirimler</figcaption></figure><p>Sevgili Medium Okuyucuları,</p><p>Bu eğitimde, OneSignal kullanarak Swift uygulamanız için anlık bildirimleri ayarlama sürecinde size rehberlik edeceğim. Anlık bildirimler, kullanıcılarınızla etkileşim kurmanın ve onları ilgili bilgilerle güncel tutmanın güçlü bir yoludur. Öyleyse, başlayalım!</p><h3><strong>Adım 1: Gereksinimler</strong></h3><p>Başlamadan önce, aşağıdaki gereksinimlere sahip olduğunuzdan emin olun:</p><ul><li><a href="https://onesignal.com/"><strong>OneSignal Hesabı</strong></a>: Henüz bir OneSignal hesabınız yoksa bir OneSignal hesabı için kaydolun.</li><li><a href="https://documentation.onesignal.com/docs/keys-and-ids"><strong>OneSignal Uygulama Kimliği</strong></a><strong>:</strong> Ayarlar &gt; Anahtarlar ve Kimlikler bölümünden OneSignal Uygulama Kimliğinizi edinin.</li><li>iOS 11+ veya iPadOS 11+ aygıt: Anlık bildirimleri test etmek için iOS 11 veya sonraki bir sürümü çalıştıran bir iPhone, iPad veya iPod Touch’a ihtiyacınız olacaktır. Xcode 14+ simülatörü iOS 16+ ile de çalışır.</li><li>Xcode 12+ ile Mac: Xcode sürüm 12 veya üzeri yüklü bir Mac bilgisayarınız olduğundan emin olun.</li><li><a href="https://documentation.onesignal.com/docs/ios-p8-token-based-connection-to-apns"><strong>p8 Kimlik Doğrulama Anahtarı</strong></a> veya <a href="https://documentation.onesignal.com/docs/ios-p12-generate-certificates"><strong>p12 Anlık Bildirim Sertifikası</strong></a>: Bir p8 kimlik doğrulama anahtarına veya bir p12 anlık bildirim sertifikasına ihtiyacınız olacak. Bu eğitim için bir p8 kimlik doğrulama anahtarı kullanacağız.</li></ul><p><strong>1.1 Yeni bir p8 anahtarı oluşturun</strong></p><ul><li><a href="https://developer.apple.com/">Ücretli Apple Geliştirici Hesabınızda</a> oturum açın ve Certificates, Identifiers &amp; Profiles &gt; Keys bölümüne gidin.</li><li>Yeni bir anahtar oluşturmak için mavi “+” düğmesine tıklayın.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCNSx2WFYdVeDQGyKIqc0w.png" /><figcaption>Apple Developer Hesabı — Anahtarlar Sayfası</figcaption></figure><p>“Apple Push Notifications service (APNs)” öğesini seçin ve anahtar için bir ad girin.</p><ul><li>İstemler boyunca devam edin ve son sayfada “Kayıt Ol” seçeneğine tıklayın.</li><li>Yeni oluşturulan anahtarı indirin ve güvenli bir şekilde kaydedin. Sadece bir kez indirebileceğinizi unutmayın.</li><li>İşlemi tamamlamak için “Bitti ”ye tıklayın.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U0gHtMiq6gx3irmLHOaIUQ.png" /><figcaption>Apple Developer Hesabı — Yeni Anahtar Kaydı Sayfası. APN’leri seçin.</figcaption></figure><p><strong>1.2 Push Anahtarınızı OneSignal’a Yükleyin</strong></p><ul><li>OneSignal kontrol paneline gidin, uygulamanızı seçin ve Ayarlar’a gidin.</li><li>Seçeneklerden “Apple iOS ”u seçin.</li><li>Daha önce indirdiğiniz <strong><em>.p8</em></strong> dosyasını yükleyin.</li><li>Ayrıca <a href="https://developer.apple.com/account"><strong>Key ID</strong></a>, <a href="https://developer.apple.com/account"><strong>Team ID</strong></a> ve App Bundle ID girin. Bu ayrıntıları Apple Developer hesabınızın keys bölümünde bulabilirsiniz.</li><li>Devam etmek için “Kaydet ve Devam Et ”e tıklayın.</li><li>“Native iOS”u seçin.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IegXkNlhkzuh65y7E5qBSg.png" /><figcaption>.p8 dosyanızı OneSignal’a yüklemek için Apple iOS (APN’ler) Yapılandırma Sayfası.</figcaption></figure><h3>Adım 2: Bir Bildirim Hizmeti Uzantısı Ekleyin</h3><p>Bildirim Hizmeti Uzantısı, uygulamanızın resimler, düğmeler ve rozetlerle zengin bildirimler almasını sağlar. OneSignal’ın analitik özellikleri için de gereklidir.</p><p>2.1 Xcode’da <strong>File &gt; New&gt; Target…🎯</strong> öğesini seçin.</p><p>2.2 “<strong>Notification Service Extension</strong>”nı seçin ve <strong>İleri</strong>’ye tıklayın.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4-UxZQlueGP4A3D04r94w.png" /><figcaption>Notification Service Extension</figcaption></figure><p>2.3 Product Name i “<strong>OneSignalNotificationServiceExtension</strong>” olarak girin ve Finish’e basın. Not: Sorulduğunda Etkinleştir’i seçmeyin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2f2u_xcoGyIRhyA9QaVCA.png" /><figcaption>OneSignalNotificationServiceExtension</figcaption></figure><p>2.4 Şemayı etkinleştir istemini iptal edin. Bu, Xcode’un yeni oluşturulan uzantı yerine uygulamanızda hata ayıklamaya devam etmesini sağlar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*q0WD1z47NGbvZke3Hkx7Gg.png" /><figcaption>Don’t Activate</figcaption></figure><p>2.5 Proje gezgininde, üst düzey proje dizinini seçin ve “<strong>OneSignalNotificationServiceExtension</strong>” hedefini seçin. Dağıtım Hedefinin ana uygulama hedefinizle aynı değere ayarlandığından emin olun. Zengin Medya desteği için Dağıtım Hedefinin iOS 15 veya üstü olarak ayarlanması önerilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjRbQhQH-Lp1UWl_2H8tJQ.png" /></figure><h3><strong>Adım 3: OneSignal SDK’yı Xcode projenize ekleyin</strong></h3><p>OneSignal SDK’yı içe aktarmanın birden fazla yolu vardır, ancak biz bu eğitimde CocoaPods’u kullanacağız.</p><p>3.1 Mevcut Xcode projenizi kapatın ve Terminal’i açın.</p><p>3.2 Terminal’de proje dizininize gidin ve bir Podfile oluşturmak için “<strong>pod init”</strong>i çalıştırın.</p><p>3.3 Oluşturulan Pod dosyasını tercih ettiğiniz kod düzenleyicisi ile açın ve aşağıdaki satırları ekleyin:</p><pre>target &#39;your_project_name&#39; do<br>  pod &#39;OneSignal/OneSignal&#39;, &#39;&gt;= 5.0.0&#39;, &#39;&lt; 6.0&#39;<br>  pod &#39;OneSignal/OneSignalInAppMessages&#39;, &#39;&gt;= 5.0.0&#39;, &#39;&lt; 6.0&#39;<br>  # If your app does not use CoreLocation, you can remove this:<br>  pod &#39;OneSignal/OneSignalLocation&#39;, &#39;&gt;= 5.0.0&#39;, &#39;&lt; 6.0&#39;<br>  # Your other pods here<br>end<br><br>target &#39;OneSignalNotificationServiceExtension&#39; do<br>  pod &#39;OneSignal/OneSignal&#39;, &#39;&gt;= 5.0.0&#39;, &#39;&lt; 6.0&#39;<br>  pod &#39;OneSignal/OneSignalInAppMessages&#39;, &#39;&gt;= 5.0.0&#39;, &#39;&lt; 6.0&#39;<br>  # If your app does not use CoreLocation, you can remove this:<br>  pod &#39;OneSignal/OneSignalLocation&#39;, &#39;&gt;= 5.0.0&#39;, &#39;&lt; 6.0&#39;<br>end</pre><p>your_project_name yerine projenizin gerçek adını yazdığınızdan emin olun.</p><p>3.5 Pod dosyasını kaydedin ve Terminal’de aşağıdaki komutları çalıştırın</p><pre>pod install --repo-update</pre><p>3.6 Yeni oluşturulan “&lt;proje-adı&gt;.xcworkspace” dosyasını açın. Şu andan itibaren, projenizi her zaman workspace kullanarak açın.</p><h3><strong>Adım 4: Gerekli Capability’leri Ekleyin</strong></h3><p>Projenizin uzaktan bildirimleri alabilmesini sağlamak için aşağıdaki adımları izleyin:</p><p>4.1 Xcode’un proje gezgininde ana uygulama hedefinizi seçin ve “Signing &amp; Capabilities”e gidin.</p><p>4.2 Anlık Bildirimler etkin değilse, “+ Capability” seçeneğine tıklayın ve “Push Notifications” ekleyin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3ZAmd6Ar8B9L91JGssl2Q.png" /><figcaption>Push Notifications</figcaption></figure><p>4.3 Tekrar “+ Capability” üzerine tıklayın, “Background Modes”u seçin ve “Remote Notifications”u etkinleştirin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wChAEPaLfW5pHxxfO7MWA.png" /><figcaption>Background Modes -&gt; Remote notifications</figcaption></figure><h3><strong>Adım 5: OneSignal Initialization Kodunu Ekleyin</strong></h3><p>Swift uygulamanızda, dosyanızı aşağıdaki kodla güncelleyin:</p><ul><li><strong>Storyboard</strong></li></ul><p>AppDelegate.swift</p><pre>import UIKit<br>import OneSignalFramework<br><br>@UIApplicationMain<br>class AppDelegate: UIResponder, UIApplicationDelegate {<br>  <br>func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: <br>[UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>  <br>  // Remove this method to stop OneSignal Debugging<br>  OneSignal.Debug.setLogLevel(.LL_VERBOSE)<br>  <br>  // OneSignal initialization<br>  OneSignal.initialize(&quot;YOUR_ONESIGNAL_APP_ID&quot;, withLaunchOptions: launchOptions)<br>  <br>  // requestPermission will show the native iOS notification permission prompt.<br>  // We recommend removing the following code and instead using an In-App Message to prompt for notification permission<br>  OneSignal.Notifications.requestPermission({ accepted in<br>    print(&quot;User accepted notifications: \(accepted)&quot;)<br>  }, fallbackToSettings: true)<br>  <br>  // Login your customer with externalId<br>  // OneSignal.login(&quot;EXTERNAL_ID&quot;)<br>  <br>  return true<br>}<br>  <br>// Remaining contents of your AppDelegate Class...<br>}</pre><p>‘YOUR_ONESIGNAL_APP_ID’ yerine OneSignal App ID ‘nizi yazdığınızdan emin olun.</p><ul><li><strong>SwiftUI</strong></li></ul><p>APP_NAMEApp.swift</p><pre>import SwiftUI<br>import OneSignalFramework<br><br>@main<br>struct YOURAPP_NAME: App {<br>    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate<br>    <br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>        }<br>    }<br>}<br><br>class AppDelegate: NSObject, UIApplicationDelegate {<br>    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -&gt; Bool {<br>       // Remove this method to stop OneSignal Debugging<br>       OneSignal.Debug.setLogLevel(.LL_VERBOSE)<br>        <br>       // OneSignal initialization<br>       OneSignal.initialize(&quot;YOUR_ONESIGNAL_APP_ID&quot;, withLaunchOptions: launchOptions)<br><br>       // requestPermission will show the native iOS notification permission prompt.<br>       // We recommend removing the following code and instead using an In-App Message to prompt for notification permission<br>       OneSignal.Notifications.requestPermission({ accepted in<br>         print(&quot;User accepted notifications: \(accepted)&quot;)<br>       }, fallbackToSettings: true)<br><br>       // Login your customer with externalId<br>       // OneSignal.login(&quot;EXTERNAL_ID&quot;)<br>            <br>       return true<br>    }<br>}</pre><p>‘YOURAPP_NAME’ yerine uygulamanızın adını ve ‘YOUR_ONESIGNAL_APP_ID’ yerine OneSignal App ID’nizi yazdığınızdan emin olun.</p><ul><li><strong>OneSignalNotificationServiceExtension</strong></li></ul><p>Proje gezgininde <strong>OneSignalNotificationServiceExtension</strong> klasörünü seçin ve<strong> NotificationService.m</strong> veya <strong>NotificationService.swift</strong> dosyasını açın.</p><p>Tüm dosyanın içeriğini aşağıdaki kodla değiştirin.</p><pre>import UserNotifications<br><br>import OneSignalExtension<br><br>class NotificationService: UNNotificationServiceExtension {<br>    <br>    var contentHandler: ((UNNotificationContent) -&gt; Void)?<br>    var receivedRequest: UNNotificationRequest!<br>    var bestAttemptContent: UNMutableNotificationContent?<br>    <br>    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -&gt; Void) {<br>        self.receivedRequest = request<br>        self.contentHandler = contentHandler<br>        self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)<br>        <br>        if let bestAttemptContent = bestAttemptContent {<br>            /* DEBUGGING: Uncomment the 2 lines below to check this extension is executing<br>                          Note, this extension only runs when mutable-content is set<br>                          Setting an attachment or action buttons automatically adds this */<br>            // print(&quot;Running NotificationServiceExtension&quot;)<br>            // bestAttemptContent.body = &quot;[Modified] &quot; + bestAttemptContent.body<br>            <br>            OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)<br>        }<br>    }<br>    <br>    override func serviceExtensionTimeWillExpire() {<br>        // Called just before the extension will be terminated by the system.<br>        // Use this as an opportunity to deliver your &quot;best attempt&quot; at modified content, otherwise the original push payload will be used.<br>        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {<br>            OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)<br>            contentHandler(bestAttemptContent)<br>        }<br>    }  <br>}</pre><h3><strong>Adım 6: App Groups Ekleme</strong></h3><p>App Groups, uygulama etkin olmasa bile uygulamanızın bildirim alırken kod çalıştırmasına olanak tanır. Bu, rozetler ve onaylanmış teslimatlar gibi özellikler için gereklidir.</p><p>6.1 “<strong>App Groups</strong>” Özelliğini Etkinleştirin:</p><ul><li>Ana uygulama hedefinizde, “Signing &amp; Capabilities” &gt; “All” seçeneğine gidin.</li><li>Uygulamanızda henüz App Groups yoksa, “+ Capability“ e tıklayın ve “App Groups” u seçin.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHtG7jrUH5wfqrcSicYXPg.png" /><figcaption>App Groups</figcaption></figure><ul><li>App Groups altında “+” düğmesine tıklayın ve konteyneri “<strong>group.YOUR_BUNDLE_IDENTIFIER.onesignal</strong>” olarak ayarlayın; burada YOUR_BUNDLE_IDENTIFIER ana uygulama hedefinizin Paket Tanımlayıcısıdır. Tamam’a tıklayın.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*ZbJ_zO4lhdgE5vnlAyw-Mg.png" /><figcaption>Yeni container ekleme &lt;group.YOUR_BUNDLE_ID.onesignal&gt;</figcaption></figure><ul><li><strong>OneSignalNotificationServiceExtension</strong> hedefi için yukarıdaki adımları tekrarlayın ve App Groups kapsayıcısının OneSignalNotificationServiceExtension hariç ana uygulama hedefiyle aynı olduğundan emin olun.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KeMRV-PFN1vDN3h_YZCSsw.png" /><figcaption>Yeni container ekleme &lt;group.YOUR_BUNDLE_ID.onesignal&gt;</figcaption></figure><h3><strong>Adım 7: Uygulamanızı Çalıştırın ve Kendinize Bir Bildirim Gönderin</strong></h3><p>Doğru şekilde derlendiğinden emin olmak için uygulamanızı fiziksel bir iOS aygıtında çalıştırın. iOS Simülatörünün uzaktan anlık bildirim almayı desteklemediğini unutmayın.</p><h3>Hata Yönetimi</h3><ul><li><strong>Sandbox hatası</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*zvQBYPvgRi9MwTdmqgDOLQ.png" /><figcaption>Sandbox hatası</figcaption></figure><blockquote>Görseldeki gibi hata alırsanız Ana uygulama hedefinizdeki “<strong>Build Settings</strong>” e tıklayın. “<strong>User Script Sandboxing</strong>” seçeneğini “<strong>No</strong>” yapın.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EoMeIXEi7bz71wVc2MB5Rw.png" /><figcaption>User Script Sandboxing -&gt; No</figcaption></figure><p>İşte bu kadar! OneSignal kullanarak Swift uygulamanız için anlık bildirimleri ayarladınız.</p><blockquote><a href="https://documentation.onesignal.com/docs/ios-sdk-setup">https://documentation.onesignal.com/docs/ios-sdk-setup</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=352d836a174a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>