{"id":305045,"date":"2020-06-09T09:00:11","date_gmt":"2020-06-09T09:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305045"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305045","title":{"rendered":"React Native: Push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e AWS Amplify"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/505990\/\">\n<p>Push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u0430\u044e\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441 \u043d\u0443\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, Amplify \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0441\u043b\u0443\u0433\u0438 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438 SDK \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/942\/0e0\/a51\/9420e0a51c7b345d8fa5d5e29d760ea0.png\" alt=\"Step01\"><\/p>\n<p>  <\/p>\n<h2 id=\"sozdaem-novyy-proekt-\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \ufe0f<\/h2>\n<p>  <\/p>\n<pre><code class=\"bash\">npx react-native init amplifyPush<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">cd amplifyPush<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 React Native \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c AWS Amplify <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">amplify init<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u0432\u0435\u0447\u0430\u0435\u043c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/236\/6a2\/38e\/2366a238ed6859de5b34c52e6f320fac.png\" alt=\"Initialize Amplify\"><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f <\/p>\n<p>  <\/p>\n<h2 id=\"stavim-zavisimosti\">\u0421\u0442\u0430\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/h2>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn add aws-amplify @aws-amplify\/pushnotification<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438\u043b\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npm install --save aws-amplify @aws-amplify\/pushnotification<\/code><\/pre>\n<p>  <\/p>\n<p>\u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">react-native link @aws-amplify\/pushnotification<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u044d\u0442\u0443 <a href=\"https:\/\/github.com\/aws-amplify\/amplify-js\/issues\/5010\" rel=\"nofollow\">\u043e\u0448\u0438\u0431\u043a\u0443<\/a> \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>netinfo<\/code>. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0433\u043e \u043d\u0435\u0442):<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn add @react-native-community\/netinfo<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">npm install --save @react-native-community\/netinfo<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/631\/e00\/e86\/631e00e866d9fc3d76c43b97781ae3b4.png\" alt=\"Step02\"><\/p>\n<p>  <\/p>\n<h2 id=\"android---nastroyka-firebase\">Android \u2014 \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Firebase<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <a href=\"https:\/\/console.firebase.google.com\/\" rel=\"nofollow\">Firebase \u043a\u043e\u043d\u0441\u043e\u043b\u044c<\/a>.<\/li>\n<li>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Cloud Messaging<\/code> \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/15a\/1c4\/0bb\/15a1c40bb8d4e5a08111463bc892c0bf.png\" alt=\"Cloud Messaging\"><\/p>\n<p>  <\/p>\n<ol>\n<li>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 Android \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/li>\n<\/ol>\n<p>  <\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0444\u043e\u0440\u043c\u0443 \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <code>Android package name<\/code> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <code>android\/app\/build.gradle<\/code>. \u0425\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 <code>applicationId<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">   defaultConfig {     applicationId &quot;com.amplifypush&quot;     ...<\/code><\/pre>\n<p>  <\/li>\n<li>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 <code>android\/app<\/code>.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 Firebase SDK. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <code>&lt;project&gt;<\/code> <code>android<\/code> \u0438 <code>&lt;app-module&gt;<\/code> <code>app<\/code><br \/>  \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0432 react native \u043f\u0440\u043e\u0435\u043a\u0442. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e <code>firebase-messaging<\/code> <a href=\"https:\/\/firebase.google.com\/docs\/android\/setup#available-libraries\" rel=\"nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a> \u0430 \u0442\u0430\u043a\u0436\u0435<br \/>  <code>firebase-analytics<\/code> \u0432 <code>dependencies<\/code>.<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Android \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0442 Firebase. (\u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0448\u0430\u0433).<\/li>\n<li>\n<p>\u041e\u0442\u043a\u0440\u044b\u0439\u0442\u0435 <code>android\/app\/src\/main\/AndroidManifest.xml<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <code>application<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;!--[START Push notification config --&gt;      &lt;!-- [START firebase_service] --&gt;      &lt;service          android:name=&quot;com.amazonaws.amplify.pushnotification.RNPushNotificationMessagingService&quot;&gt;          &lt;intent-filter&gt;              &lt;action android:name=&quot;com.google.firebase.MESSAGING_EVENT&quot;\/&gt;          &lt;\/intent-filter&gt;      &lt;\/service&gt;      &lt;!-- [END firebase_service] --&gt;      &lt;!-- [START firebase_iid_service] --&gt;      &lt;service          android:name=&quot;com.amazonaws.amplify.pushnotification.RNPushNotificationDeviceIDService&quot;&gt;          &lt;intent-filter&gt;              &lt;action android:name=&quot;com.google.firebase.INSTANCE_ID_EVENT&quot;\/&gt;          &lt;\/intent-filter&gt;      &lt;\/service&gt;      &lt;receiver          android:name=&quot;com.amazonaws.amplify.pushnotification.modules.RNPushNotificationBroadcastReceiver&quot;          android:exported=&quot;false&quot; &gt;          &lt;intent-filter&gt;              &lt;action android:name=&quot;com.amazonaws.amplify.pushnotification.NOTIFICATION_OPENED&quot;\/&gt;          &lt;\/intent-filter&gt;      &lt;\/receiver&gt;  &lt;!-- [END Push notification config --&gt;<\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9eb\/aa1\/4a1\/9ebaa14a1b87631ab663427182eb87cd.png\" alt=\"Step03\"><\/p>\n<p>  <\/p>\n<h2 id=\"nastroyka-amplify-dlya-fcm\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Amplify \u0434\u043b\u044f FCM<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0443\u0436\u0431\u0443 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<br \/> \n<pre><code class=\"bash\">amplify add notifications<\/code><\/pre>\n<\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>FCM<\/code>:<br \/> \n<pre><code class=\"plaintext\">? Choose the push notification channel to enable. APNS \u276f FCM Email SMS<\/code><\/pre>\n<\/li>\n<li>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u043e\u0447\u043d\u043e\u0435 \u0438\u043c\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u0432\u0432\u043e\u0434, \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u043d\u0438\u0447\u0435\u0433\u043e).<\/li>\n<li>\u0423 \u0432\u0430\u0441 \u0441\u043f\u0440\u043e\u0441\u044f\u0442 <code>ApiKey<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<br \/> \n<ul>\n<li>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <a href=\"https:\/\/console.firebase.google.com\/\" rel=\"nofollow\">Firebase \u043a\u043e\u043d\u0441\u043e\u043b\u044c <\/a> \u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0448\u0430\u0433\u0430\u0445.<\/li>\n<li>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u043e\u043a \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>Project Overview<\/code> \u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Project settings<\/code>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ea\/4aa\/d4c\/8ea4aad4c88d205a2f3ea7904f07b8fc.png\" alt=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\"><\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>Cloud Messaging<\/code> \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Server key<\/code>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6df\/eae\/05c\/6dfeae05c6bfffbfe50e3bcdea666a45.png\" alt=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\"><\/li>\n<\/ul>\n<\/li>\n<li>\u0412\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f <code>ApiKey<\/code>.<\/li>\n<li>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>amplify push<\/code>.<\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/af4\/70f\/d98\/af470fd981fa96a00da9992a9a7e6924.png\" alt=\"Step04\"><\/p>\n<p>  <\/p>\n<h2 id=\"ios---nastroyka\">iOS \u2014 \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/h2>\n<p>  <\/p>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c <code>@react-native-community\/push-notification-ios<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">npm install @react-native-community\/push-notification-ios<\/code><\/pre>\n<p>  <\/p>\n<p>or<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn add @react-native-community\/push-notification-ios`<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f iOS:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd ios &amp;&amp; pod install &amp;&amp; cd ..<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f ios \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>amplify add notifications<\/code> :<\/p>\n<p>  <\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 <code>APNS<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">? Choose the push notification channel to enable. &gt; APNS FCM Email SMS<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">? Choose authentication method used for APNs (Use arrow keys) &gt; Certificate Key<\/code><\/pre>\n<p>  <\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0443 .p12. (\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 <a href=\"https:\/\/mobincube.zendesk.com\/hc\/en-us\/articles\/200511933-How-to-get-the-p12-file-and-provisioning-profile-for-publishing-an-app-on-App-Store\" rel=\"nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b<\/a>).<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>amplify push<\/code>.<\/li>\n<li>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <code>.xcworkspace<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e XCode.<\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>TARGETS<\/code>. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Signing &amp; Capabilities<\/code> \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 <code>+<\/code> \u043f\u0435\u0440\u0435\u0434<code>Capability<\/code>. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Background Mode - Remote Notifications<\/code>.<\/li>\n<\/ol>\n<p>  <\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d23\/840\/9a4\/d238409a47778024c1f12cd93691c3ab.png\" alt=\"Step05\"><\/p>\n<p>  <\/p>\n<h2 id=\"nastroyka-prilozheniya\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0440\u0430\u043d\u0435\u0435, <code>Analytics<\/code> \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u0425\u043e\u0442\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b <code>aws-exports<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0412 <code>App.js<\/code> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">... import Amplify from 'aws-amplify' import PushNotification from '@aws-amplify\/pushnotification' import awsconfig from '.\/aws-exports'  Amplify.configure(awsconfig)  PushNotification.configure(awsconfig) ...<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d23\/840\/9a4\/d238409a47778024c1f12cd93691c3ab.png\" alt=\"Step05\"><\/p>\n<p>  <\/p>\n<h2 id=\"working-with-api\">Working with API<\/h2>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"onregister\">onRegister<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e push-\u0442\u043e\u043a\u0435\u043d\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u0432\u044b\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u043d\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u0441\u043d\u043e\u0432\u0430 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0438\u043c.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <code>App.js<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">PushNotification.onRegister((token) =&gt; {   console.log('in app registration', token)   PushNotification.updateEndpoint(token) })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043d\u0438\u043c\u0435\u043d\u0438\u0435!<br \/>  \u0412 Android \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d! \u041e\u0434\u043d\u0430\u043a\u043e <a href=\"https:\/\/github.com\/aws-amplify\/amplify-js\/issues\/2643#issuecomment-523610933\" rel=\"nofollow\">\u043e\u0431\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0443\u0442\u044c<\/a> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043a\u0435\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">... import {NativeModules} from 'react-native' ... NativeModules.RNPushNotification.getToken((token) =&gt; {   console.log(`PushToken: ${token}`) }) ...<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"onnotification\">onNotification<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e, \u043c\u0435\u0442\u043e\u0434 <code>onNotification<\/code> \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 Android \u0438 iOS. \u0412 iOS, \u0412\u0430\u043c <a href=\"https:\/\/reactnative.dev\/docs\/pushnotificationios.html#finish\" rel=\"nofollow\">\u0441\u043b\u0435\u0434\u0443\u0435\u0442<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>finish<\/code>. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <code>App.js<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">... import PushNotificationIOS from '@react-native-community\/push-notification-ios' ... PushNotification.onNotification((notification) =&gt; {   console.log('in app notification', notification)   if (Platform.OS === 'ios') {     notification.finish(PushNotificationIOS.FetchResult.NoData)   } })<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"onnotificationopened\">onNotificationOpened<\/h2>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u2014 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>onNotificationOpened<\/code>. <code>App.js<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">PushNotification.onNotificationOpened((notification) =&gt; {     console.log('the notification is opened', notification) })<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"requestiospermissions\">requestIOSPermissions<\/h2>\n<p>  <\/p>\n<p>Push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0434\u0430\u0441\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435. <code>requestIOSPermissions<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0438\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"> PushNotification.requestIOSPermissions() \/\/ or PushNotification.requestIOSPermissions({   alert: true,   badge: true,   sound: false, })<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/34b\/ec2\/c86\/34bec2c860805fdf4daca2f36ec985fe.png\" alt=\"Step06\"><\/p>\n<p>  <\/p>\n<h2 id=\"testirovanie\">\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0444\u0430\u0439\u043b <code>App.js<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">import React from 'react' import {SafeAreaView, Platform, Text, NativeModules} from 'react-native'  import PushNotificationIOS from '@react-native-community\/push-notification-ios' import Analytics from '@aws-amplify\/analytics' import Amplify from 'aws-amplify' import PushNotification from '@aws-amplify\/pushnotification' import awsconfig from '.\/aws-exports'  Amplify.configure(awsconfig) PushNotification.configure(awsconfig)  PushNotification.onRegister(async (token) =&gt; {   console.log('in app registration', token)   PushNotification.updateEndpoint(token) })  \/\/ In case PushNotification.onRegister didn't work NativeModules.RNPushNotification.getToken((token) =&gt; {   console.log(`PushToken: ${token}`) })  PushNotification.onNotification((notification) =&gt; {   console.log('in app notification', notification)   if (Platform.OS === 'ios') {     notification.finish(PushNotificationIOS.FetchResult.NoData)   } })  PushNotification.onNotificationOpened((notification) =&gt; {   console.log('the notification is opened', notification) })  const endpointId = Analytics.getPluggable('AWSPinpoint')._config.endpointId console.log(`endpoint ID: ${endpointId}`)  if (Platform.OS === 'ios') {   PushNotification.requestIOSPermissions() }  const App: () =&gt; React$Node = () =&gt; {   return (     &lt;SafeAreaView&gt;       &lt;Text&gt;Push Notification&lt;\/Text&gt;     &lt;\/SafeAreaView&gt;   ) }  export default App <\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">react-native run-android<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">react-native run-ios<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043e\u0434\u0438\u043d \u0438\u0437 <code>endpoint ID<\/code> \u0438\u043b\u0438 <code>Push Token<\/code>.<br \/>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043e <a href=\"https:\/\/docs.aws.amazon.com\/pinpoint\/latest\/apireference\/apps-application-id-endpoints.html\" rel=\"nofollow\">\u0442\u0443\u0442<\/a> <code>endpoint<\/code> \u0432 <code>aws<\/code> \u0443\u0441\u043b\u0443\u0433\u0430\u0445:<\/p>\n<p>  <\/p>\n<blockquote><p><code>Endpoint<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u043d\u043a\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0438\u043b\u0438 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.<\/p><\/blockquote>\n<p><code>Push Token<\/code> \u044d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442<code>GCM<\/code>(Android) \u0438\u043b\u0438 <code>APNS<\/code>(IOS) \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>endpoint<\/code> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437<br \/>  <code>aws<\/code>, \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b (IOS \/ Android). \u041d\u043e \u0442\u043e\u043a\u0435\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u043e\u0442 <code>Apple<\/code> \u0438\u043b\u0438 <code>Google<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>console.log<\/code> \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u044d\u0442\u0438 \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u043e\u0432. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2a4\/007\/252\/2a4007252e8002a9018b187497c7d950.png\" alt=\"Tokens\"><\/p>\n<p>  <\/p>\n<p>\u0425\u043e\u0442\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u043c\u044b \u0438\u0437\u0443\u0447\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<p>  <\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">amplify notification console<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u041a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<p>  <\/li>\n<li>\n<p>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Test messaging<\/code> \u0432 \u043b\u0435\u0432\u043e\u0439 \u0431\u043e\u043a\u043e\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/516\/839\/cca\/516839cca332cbc4d7b69fc2fe3fa058.png\" alt=\"Test messaging\"><\/p>\n<p>  <\/li>\n<li>\n<p>\u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>Channel<\/code>, \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Push notifications<\/code>.<\/p>\n<p>  <\/li>\n<li>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b <code>Destinations<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/73d\/e67\/dd0\/73de67dd0b692915fea94f53e1405bff.png\" alt=\"Destinations\"> <\/p>\n<p>  <\/li>\n<li>\n<p><code>Destination type<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Endpoint IDs<\/code> \u0438\u043b\u0438 <code>Device Tokens<\/code>(\u0438\u043b\u0438 <code>Push token<\/code> \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0448\u0430\u0433\u0430\u0445) \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0432\u043e\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>  <\/li>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>Destination type<\/code>.<\/p>\n<p>  <\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <code>Endpoint IDs<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443, \u0442\u043e <code>\u0421\u043b\u0443\u0436\u0431\u0430 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439<\/code> \u043c\u043e\u0436\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>Device token<\/code>, \u0434\u043b\u044f IOS \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>APNS<\/code>, \u0430 \u0434\u043b\u044f Android \u2014 <code>FCM<\/code>.<\/p>\n<p>  <\/li>\n<li>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b <code>Message<\/code>, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u0438 \u043d\u0430\u0436\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 <code>Send message<\/code>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bd1\/2bc\/68c\/bd12bc68ce4edf2272943dba2e5d381c.png\" alt=\"Destinations\"><\/p>\n<p>  <\/li>\n<li>\n<p>\u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0445\u0435, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<p>  <\/li>\n<\/ol>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/63c\/c1b\/bf6\/63cc1bbf66549fed207fb880b01367f8.png\" alt=\"Success\"><\/p>\n<p>  <\/p>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u0441\u0435\u043a\u0443\u043d\u0434 \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bca\/a42\/0f4\/bcaa420f49ae78b0bc30ef4f2a909c93.png\" alt=\"Push notification result\"><\/p>\n<p>  <\/p>\n<h2 id=\"done\">Done<\/h2>\n<p>  <\/p>\n<p>15 \u0438\u044e\u043d\u044f \u0441 10:00 \u2014 13:30 \u043f\u043e \u041c\u0441\u043a \u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f AWS Mobile &amp; Web Apps Day, \u0433\u0434\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0431 \u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 AWS \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Amplify \u0438 React Native.<br \/>  <a href=\"https:\/\/pages.awscloud.com\/EMEA-field-OE-AppsDay1-2020-reg-event.html?sc_channel=em&amp;trkCampaign=rucis20_AppsDay1&amp;trk=em_inv1_rucis20_AppsDay1_register&amp;sc_campaign=EMEA_FIELD_WEBINAR_mobile-web-apps-day_20200612_7010z000001LWs4&amp;sc_medium=em_252297&amp;sc_content=event_webinar_field&amp;sc_geo=emea&amp;sc_country=mult&amp;sc_outcome=event\" rel=\"nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"ssylki\">\u0421\u0441\u044b\u043b\u043a\u0438:<\/h2>\n<p>  <\/p>\n<p><a href=\"https:\/\/docs.amplify.aws\/lib\/push-notifications\/getting-started\/q\/platform\/js\" rel=\"nofollow\">Amplify Docs<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/medium.com\/@dantasfiles\/setting-up-android-push-notifications-with-aws-amplify-e6334c6356d8\" rel=\"nofollow\">Setting up Android Push Notifications with AWS Amplify<\/a><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/medium.com\/@dantasfiles\/testing-push-notifications-with-aws-amplify-9126bd621d3a\" rel=\"nofollow\">Testing Push Notifications with AWS Amplify &amp; CLI<\/a><\/p>\n<p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/505990\/\"> https:\/\/habr.com\/ru\/post\/505990\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/505990\/\">\n<p>Push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u0430\u044e\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441 \u043d\u0443\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, Amplify \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0441\u043b\u0443\u0433\u0438 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438 SDK \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305045","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305045"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305045\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}