MOBILEPROGLIB Telegram 6047
🔔 Настройка push-уведомлений в мобильных приложениях

👾 Firebase Cloud Messaging (Android)

1. Добавьте зависимости:

implementation 'com.google.firebase:firebase-messaging:23.1.0'


2. Регистрация токена:

FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
if (task.isSuccessful) {
val token = task.result
// Отправьте токен на ваш сервер
}
}


3. Обработка входящих сообщений:

class MyFirebaseService : FirebaseMessagingService() {
override fun onMessageReceived(message: RemoteMessage) {
// Создайте и отобразите уведомление
}
}


👨‍💻 Apple Push Notification Service (iOS)

1. Настройка в Xcode:

• Включите Push Notifications в Capabilities
• Зарегистрируйте сертификаты в Developer Center

2. Запрос разрешений:

UNUserNotificationCenter.current().requestAuthorization(
options: [.alert, .sound, .badge]) { granted, error in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}


3. Обработка токена устройства:

func application(_ application: UIApplication, 
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
// Отправьте токен на сервер
}


🚀 Продвинутые функции

1. Группировка уведомлений (Android):

NotificationCompat.Builder(context, CHANNEL_ID)
.setGroup("news_group")
.setGroupSummary(true)


2. Действия в уведомлениях (iOS):

let action = UNNotificationAction(
identifier: "replyAction",
title: "Ответить",
options: [.foreground])


3. Глубокая навигация:

val pendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.main_nav)
.setDestination(R.id.detailsFragment)
.createPendingIntent()


Какие лучшие практики по push-уведомлениям используете вы? Делитесь в комментариях 💬

🐸 Библиотека мобильного разработчика

#буст
Please open Telegram to view this post
VIEW IN TELEGRAM
2🥱2



tgoop.com/mobileproglib/6047
Create:
Last Update:

🔔 Настройка push-уведомлений в мобильных приложениях

👾 Firebase Cloud Messaging (Android)

1. Добавьте зависимости:

implementation 'com.google.firebase:firebase-messaging:23.1.0'


2. Регистрация токена:

FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
if (task.isSuccessful) {
val token = task.result
// Отправьте токен на ваш сервер
}
}


3. Обработка входящих сообщений:

class MyFirebaseService : FirebaseMessagingService() {
override fun onMessageReceived(message: RemoteMessage) {
// Создайте и отобразите уведомление
}
}


👨‍💻 Apple Push Notification Service (iOS)

1. Настройка в Xcode:

• Включите Push Notifications в Capabilities
• Зарегистрируйте сертификаты в Developer Center

2. Запрос разрешений:

UNUserNotificationCenter.current().requestAuthorization(
options: [.alert, .sound, .badge]) { granted, error in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}


3. Обработка токена устройства:

func application(_ application: UIApplication, 
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
// Отправьте токен на сервер
}


🚀 Продвинутые функции

1. Группировка уведомлений (Android):

NotificationCompat.Builder(context, CHANNEL_ID)
.setGroup("news_group")
.setGroupSummary(true)


2. Действия в уведомлениях (iOS):

let action = UNNotificationAction(
identifier: "replyAction",
title: "Ответить",
options: [.foreground])


3. Глубокая навигация:

val pendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.main_nav)
.setDestination(R.id.detailsFragment)
.createPendingIntent()


Какие лучшие практики по push-уведомлениям используете вы? Делитесь в комментариях 💬

🐸 Библиотека мобильного разработчика

#буст

BY Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck




Share with your friend now:
tgoop.com/mobileproglib/6047

View MORE
Open in Telegram


Telegram News

Date: |

"Doxxing content is forbidden on Telegram and our moderators routinely remove such content from around the world," said a spokesman for the messaging app, Remi Vaughn. With the sharp downturn in the crypto market, yelling has become a coping mechanism for many crypto traders. This screaming therapy became popular after the surge of Goblintown Ethereum NFTs at the end of May or early June. Here, holders made incoherent groaning sounds in late-night Twitter spaces. They also role-played as urine-loving Goblin creatures. To view your bio, click the Menu icon and select “View channel info.” Telegram channels fall into two types: The channel also called on people to turn out for illegal assemblies and listed the things that participants should bring along with them, showing prior planning was in the works for riots. The messages also incited people to hurl toxic gas bombs at police and MTR stations, he added.
from us


Telegram Библиотека мобильного разработчика | Android, iOS, Swift, Retrofit, Moshi, Chuck
FROM American