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: |

SUCK Channel Telegram During a meeting with the president of the Supreme Electoral Court (TSE) on June 6, Telegram's Vice President Ilya Perekopsky announced the initiatives. According to the executive, Brazil is the first country in the world where Telegram is introducing the features, which could be expanded to other countries facing threats to democracy through the dissemination of false content. Hui said the messages, which included urging the disruption of airport operations, were attempts to incite followers to make use of poisonous, corrosive or flammable substances to vandalize police vehicles, and also called on others to make weapons to harm police. Add up to 50 administrators A few years ago, you had to use a special bot to run a poll on Telegram. Now you can easily do that yourself in two clicks. Hit the Menu icon and select “Create Poll.” Write your question and add up to 10 options. Running polls is a powerful strategy for getting feedback from your audience. If you’re considering the possibility of modifying your channel in any way, be sure to ask your subscribers’ opinions first.
from us


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