<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>APNs &#8211; 隨心所欲</title>
	<atom:link href="https://doeverythingiwant.com/tag/apns/feed/" rel="self" type="application/rss+xml" />
	<link>https://doeverythingiwant.com</link>
	<description>iOS Developer 的隨筆記錄</description>
	<lastBuildDate>Sun, 09 Apr 2023 09:06:48 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://doeverythingiwant.com/wp-content/uploads/2025/08/cropped-0802.png</url>
	<title>APNs &#8211; 隨心所欲</title>
	<link>https://doeverythingiwant.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>[iOS] APNs 與 DeepLink 的 APP 開啟順序</title>
		<link>https://doeverythingiwant.com/ios-apns-deeplink-app/</link>
					<comments>https://doeverythingiwant.com/ios-apns-deeplink-app/#respond</comments>
		
		<dc:creator><![CDATA[艾普利]]></dc:creator>
		<pubDate>Fri, 02 Sep 2022 14:33:00 +0000</pubDate>
				<category><![CDATA[寫程式]]></category>
		<category><![CDATA[APNs]]></category>
		<category><![CDATA[iOS]]></category>
		<guid isPermaLink="false">https://doeverythingiwant.com/coding/ios-apns-deeplink-app/</guid>

					<description><![CDATA[Photo by Jamie Street on Unspl&#8230;]]></description>
										<content:encoded><![CDATA[
<p class="has-text-align-center wp-block-paragraph">Photo by <a href="https://unsplash.com/@jamie452?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" target="_blank" rel="noopener">Jamie Street</a> on <a href="https://unsplash.com/s/photos/notification?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" target="_blank" rel="noopener">Unsplash</a></p>



<p class="wp-block-paragraph">這幾天收到了關於 APNs Log Event 的傳送問題，因為這個問題才發現到 APNs 與 DeepLink 在開啟APP的 function 觸發的順序不太一樣</p>



<p class="wp-block-paragraph">簡單的說一下 APNs&nbsp; 與 DeepLink</p>



<h2 class="wp-block-heading">APNs</h2>



<p class="wp-block-paragraph">全名是 APPLE Push Notification service 的縮寫，也就是推播系統，這裡指的推播是指 Remote&nbsp; Notification ，是由遠端系統發送資訊給手機端，用途有很多種，遊戲APP最常拿來做活動通知</p>



<p class="wp-block-paragraph">想更了解APNs 可以參考APPLE 官方說明 <a rel="noreferrer noopener" href="https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1" target="_blank">APNs</a> / <a rel="noreferrer noopener" href="https://developer.apple.com/documentation/usernotifications" target="_blank">User notifications</a></p>



<h2 class="wp-block-heading">DeepLink</h2>



<p class="wp-block-paragraph">就是可以讓你自定URL Schemes，可以讓你利用這個URL來開啟APP，不過如果APP不存在是不會幫你連到APP Store 下載的</p>



<p class="wp-block-paragraph">想更了解DeepLink請參考官方說明 <a rel="noreferrer noopener" href="https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content/defining_a_custom_url_scheme_for_your_app" target="_blank">Custom url scheme</a></p>



<h2 class="wp-block-heading">Universal Link</h2>



<p class="wp-block-paragraph">另一個比較常聽到的就是Universal Link ，它並不是DeepLink，但是有相似的功能，最明顯的差異在於Universal Link 是和一般網頁一樣 https:// 開頭，而DeepLink 就是自定的如：ABC://</p>



<p class="wp-block-paragraph">可參考官方說明 <a rel="noreferrer noopener" href="https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content" target="_blank">Universal link</a></p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p class="wp-block-paragraph">回到正題</p>



<h2 class="wp-block-heading">一般Launch App 的流程</h2>



<p class="wp-block-paragraph"><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">didFinishLaunch</mark> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/27a1.png" alt="➡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">applicationDidBecomeActive</mark></strong></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading">DeepLink 開啟 App 的流程</h2>



<p class="wp-block-paragraph"><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">didFinishLaunch</mark></strong>&nbsp; <strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/27a1.png" alt="➡" class="wp-smiley" style="height: 1em; max-height: 1em;" />&nbsp; <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-amber-color">application open url</mark>&nbsp; <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/27a1.png" alt="➡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">applicationDidBecomeActive</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" src="https://doeverythingiwant.com/wp-content/uploads/2022/10/999.png" alt="" class="wp-image-282" width="750" height="87" srcset="https://doeverythingiwant.com/wp-content/uploads/2022/10/999.png 724w, https://doeverythingiwant.com/wp-content/uploads/2022/10/999-300x35.png 300w, https://doeverythingiwant.com/wp-content/uploads/2022/10/999-600x70.png 600w" sizes="(max-width: 750px) 100vw, 750px" /></figure>



<h2 class="wp-block-heading">Push Notification 開啟 App 的流程</h2>



<p class="wp-block-paragraph"><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">didFinishLaunch</mark><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/27a1.png" alt="➡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">userNotificationCenter(_:didReceive:withCompletionHandler:) </mark><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/27a1.png" alt="➡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">applicationDidBecomeActive</mark><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/27a1.png" alt="➡" class="wp-smiley" style="height: 1em; max-height: 1em;" /><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-amber-color"> application open url</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://doeverythingiwant.com/wp-content/uploads/2022/10/009.png" alt="" class="wp-image-281" width="726" height="98" srcset="https://doeverythingiwant.com/wp-content/uploads/2022/10/009.png 613w, https://doeverythingiwant.com/wp-content/uploads/2022/10/009-300x41.png 300w, https://doeverythingiwant.com/wp-content/uploads/2022/10/009-600x81.png 600w" sizes="(max-width: 726px) 100vw, 726px" /></figure>



<p class="wp-block-paragraph">注意到<strong>applicationDidBecomeActive</strong>與 <strong>application open url</strong> 在這二個情況下的執行順序不同嗎?</p>



<p class="wp-block-paragraph">說真的平常不太會留意到這樣的情況，因為無論誰先誰後都可以順利開啟APP且執行到應該要做的事情</p>



<p class="wp-block-paragraph">這次沒有log紀錄的需求的話，也許就不會有機會發現這件有趣的事</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">希望大家 Coding 愉快~</p>
]]></content:encoded>
					
					<wfw:commentRss>https://doeverythingiwant.com/ios-apns-deeplink-app/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
