މޮބައިލް އެޕަށް ޕުޝް ނޮޓިފިކޭޝަންތައް ސެޓްއަޕް ކުރުން (FCM V1 އަދި APNs)
މޮބައިލް އެޕަށް ޕުޝް ނޮޓިފިކޭޝަންތައް ސެޓްއަޕް ކުރުން (FCM V1 އަދި APNs)
މި އިރުޝާދުގައި SMSBAT ޕުޝް ނޮޓިފިކޭޝަންތައް ތިޔަބޭފުޅުންގެ iOS އަދި Android އެޕްތަކުގައި ޖަމާކޮށްދެއެވެ.
ސްޓޭޖް 1. Firebase ޕްރޮޖެކްޓާއި ސަރވިސް އެކައުންޓް (FCM V1)
SMSBAT އިން Android އާއި iOS ދެ ޕްލެޓްފޯމުގައިވެސް FCM V1 ގެ ތެރެއިން ޕުޝް ފޮނުވައެވެ. މީގެ މާނައަކީ ތިޔަބޭފުޅުން SMSBAT އަށް އަޕްލޯޑް ކުރަންޖެހެނީ ހަމައެކަނި ފައިލް އެކެވެ: Firebase ސަރވިސް އެކައުންޓް. APNs ކީ ދުވަހަކުވެސް SMSBAT އަށް އަޕްލޯޑް ނުކުރެވެ — އެއީ Firebase އަށް ބޭނުންވާ އެއްޗެކެވެ، އަޅުގަނޑުމެންނަށް ނޫނެވެ (ސްޓޭޖް 3 ބައްލަވާ).
1. Firebase އިން ސަރވިސް އެކައުންޓް ހޯދުން
- Firebase Console → Project Settings → Service accounts ޓެބް.
- Generate new private key → ކަށަވަރުކޮށް →
.jsonފައިލެއް ޑައުންލޯޑް ވެއެވެ.
މިއީ google-services.json އާ އެއް ފައިލެއް ނޫނެވެ
google-services.json އާއި GoogleService-Info.plist ފޮނުވެނީ އެޕްގެ ތެރޭގައެވެ.
ސަރވިސް އެކައުންޓަކީ ޕްރައިވެޓް ސާވަރ ކީ އެއް ކަމުން އެކަން ހުންނަންވާނީ ހަމައެކަނި SMSBAT ގައެވެ.
އެ ފައިލް ދުވަހަކުވެސް އެޕް ކޯޑުގައި، ރިޕޮޒިޓަރީއެއްގައި، ނުވަތަ ޗެޓް މެސެޖެއްގައި ނުބަހައްޓާށެވެ.
2. SMSBAT Omni ގައި އިންޓެގްރޭޝަން އުފެއްދުން
- އިންޓެގްރޭޝަންތައް ހުޅުވާލާ ވާތް ފަރާތުގެ ލިސްޓުން Firebase ހޮވާށެވެ.
- އުފެއްދުން ފިތާށެވެ.
- ދެ ފީލްޑް ފުރިހަމަ ކުރައްވާ:
- ނަން — ލިސްޓުގައި އެޕް ދެނެގަތުމަށް އެހީތެރިވާ ޚިޔާލު ނަމެއް
(for example,
Omnichannel Contact Center). - Service account JSON — ހިޔާރުކުރުން ފިތާ ޑައުންލޯޑް ކުރި ފައިލް ހޮވާށެވެ.
- ނަން — ލިސްޓުގައި އެޕް ދެނެގަތުމަށް އެހީތެރިވާ ޚިޔާލު ނަމެއް
(for example,
- އުފެއްދުން ފިތާށެވެ.
މިތަނުގައި ޕެކޭޖް ނަމަށް ނުވަތަ bundle ID އަށް ފީލްޑެއް ނެތެވެ — SMSBAT އިން Project ID ފައިލުން އަމިއްލައަށް ކިޔައި ޓޭބަލްގައި ދައްކައެވެ.
3. އިންޓެގްރޭޝަން ހިނގާތޯ ބެލުން
ނަން، Project ID، ހާލަތު އަދި ހެދި ތާރީޚް ހުރި ކޮޅެއް ފެނިގެންދެއެވެ. ރަނގަޅު ހާލަތަކީ ހަރަކާތްތެރި އެވެ.
ކޮޅުގެ ނިމުމުގައިވާ ބަޓަންތައް:
| ބަޓަން | އެކްޝަން |
|---|---|
| ޕެންސިލް (ނީލަ) | ނަން ބަދަލުކުރުން ނުވަތަ ސަރވިސް އެކައުންޓް ފައިލް ބަދަލުކުރުން |
| ރިފްރެޝް (ފެހި) | ކީ އަލުން ކިޔާ FCM އަށް ވަނުމުގެ ހުއްދަ އަލުން ބެލުން |
| ބިން (ރަތް) | އިންޓެގްރޭޝަން ފޮހެލުން |
Project ID އަކީ ތިޔަބޭފުޅުންގެ އެޕްގައިވާ ID އާ އެއްގޮތް ވާންޖެހޭ ކަމެކެވެ
ޓޭބަލްގައިވާ Project ID އާ google-services.json (Android) އަދި
GoogleService-Info.plist (iOS) ގައިވާ project_id ބަލާބަލާ ބެލުއްވާ. އެއްގޮތް
ނުވާނަމަ، އެޕް ރަޖިސްޓަރ ކޮށްފައިވަނީ ވަކި Firebase ޕްރޮޖެކްޓެއްގައި ކަމާއި SMSBAT ފޮނުވަނީ
އެހެން އެއްގައި ކަމެވެ. ޓޯކަންތައް ރަނގަޅު ހެން ފެންނާނެ، އެއްވެސް އެއްޗެއް ނުލިބޭނެ، އަދި އެއްވެސް އެރަރެއް
ރިޓާން ނުކުރެވޭނެއެވެ. މިއީ “ހުރިހާ ކަމެއް ކޮންފިގަރ ކޮށްފައި އެކަމަކު
އެއްވެސް އެއްޗެއް ނުލިބެއެވެ” މައްސަލައިގެ ގިނައިން ދިމާވާ ސަބަބެވެ.
Firebase ގައި ކީ ބަދަލުކޮށްފިނަމަ، ޕެންސިލް ބަޓަނުން އާ ފައިލް އަޕްލޯޑް ކޮށް ފެހި ބަޓަން ފިތާށެވެ. ބާތިލްކުރެވިފައިވާ ކީ އަޑެއް ނެތި ބަލައްވާލާ ވަގުތަށް ހުއްޓެއެވެ.
4. އެޕްލިކޭޝަން ކީ
އެޕުން SMSBAT Push API އަށް ފޮނުވާ ރިކުއެސްޓްތައް އޮތެންޓިކޭޓް ކުރެވެނީ Omni ޕެނަލްގައި ތިޔަބޭފުޅުންގެ އެޕަށް ދޫކުރެވޭ އެޕްލިކޭޝަން ކީ އިންނެވެ، އެއީ ހެޑަރެއްގެ ގޮތުގައި ފޮނުވޭ:
X-Push-App-Key: <application key>
ރިކުއެސްޓްގެ ފުރިހަމަ ރިފަރެންސަށް Push API އެކުލެވުން ބައްލަވާ.
ސްޓޭޖް 2. Android (Kotlin / Java)
1. ޑިޕެންޑެންސީތައް
ތިޔަބޭފުޅުންގެ މޮޑިއުލްގެ build.gradle ގައި:
dependencies {
implementation 'com.google.firebase:firebase-messaging-ktx:23.4.0'
implementation 'com.google.firebase:firebase-installations-ktx:17.2.0'
}
2. Firebase Installation ID (FID) ރަޖިސްޓަރ ކުރުން
ޔޫޒަރު ސައިން އިން ވުމުން ނުވަތަ އެޕް ފެށުމުން FID ކިޔައި SMSBAT އަށް ފޮނުވާ:
FirebaseInstallations.getInstance().id.addOnCompleteListener { task ->
if (task.isSuccessful) {
val fid = task.result
registerInstallationOnSmsbat(fid, currentUserId)
}
}
fun registerInstallationOnSmsbat(fid: String, userId: String) {
val json = JSONObject().apply {
put("externalUserId", userId)
put("firebaseInstallationId", fid)
put("platform", "android")
put("notificationsEnabled", true)
}
// HTTP POST to https://restapi.smsbat.com/api/push/registerInstallation
// Header: X-Push-App-Key = YOUR_PUSH_APP_KEY
}
3. ޕުޝް ހަވާލުކޮށް delivered ރިޕޯޓް ކުރުން
ތިޔަބޭފުޅުންގެ FirebaseMessagingService ގައި:
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
val data = remoteMessage.data
val notificationGuid = data["guid"]
if (!notificationGuid.isNullOrEmpty()) {
// 1. Confirm delivery so SMSBAT stops the cascade
sendDeliveryStatus(notificationGuid, "delivered")
}
// 2. Draw the local notification yourself (NotificationManager)
showNotification(data["title"], data["body"], data)
}
private fun sendDeliveryStatus(guid: String, status: String) {
// HTTP POST to https://restapi.smsbat.com/api/push/notifications/$guid/status
// Header: X-Push-App-Key = YOUR_PUSH_APP_KEY
// Body: { "status": "delivered", "occurredAt": "2026-08-07T12:00:00Z" }
}
}
ބެނަރު އަމިއްލައަށް ދައްކަން ޖެހޭ ސަބަބު
SMSBAT އިން ޑޭޓާ-އޮންލީ މެސެޖުތައް ފޮނުވާތީ އެޕަށް delivered ރިޕޯޓު ކުރެވޭނީ ޔޫޒަރު
އެއްޗެއް ހުޅުވުމުގެ ކުރިން ކަމުގައި ވިޔަސް އެވެ. ޑޭޓާ-އޮންލީ މެސެޖުތަކަށް ސިސްޓަމުން ބެނަރު ނުދައްކައެވެ
— އެކަން އެޕުން ކުރަންޖެހެއެވެ.
ސްޓޭޖް 3. iOS (Swift / APNs)
iOS ގައި APNs ކީ އަޕްލޯޑް ކުރެވެނީ SMSBAT އަށް ނޫން، Firebase އަށެވެ: Firebase Console → Cloud Messaging → APNs Authentication Key. ދެން FCM V1 އިން ތިޔަބޭފުޅުންގެ ބަދަލުގައި Apple އަށް ފޮނުވައިދެއެވެ.
1. Notification Service Extension އެއް އިތުރުކުރުން
ފޮނުވި ކަން ކަށަވަރުކުރުމަށާއި ގިނަ ބާވަތްތަކުގެ ކޮންޓެންޓް (ފޮޓޯ، އަޑު، ބަޓަން) ހަވާލުކުރުމަށް، Xcode ގައި Notification Service Extension ޓާގެޓެއް އިތުރުކުރައްވާ:
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
let userInfo = bestAttemptContent.userInfo
if let guid = userInfo["guid"] as? String {
// Report delivered to SMSBAT
sendPushStatus(guid: guid, status: "delivered")
}
contentHandler(bestAttemptContent)
}
}
}
2. ޓެޕް ހަވާލުކުރުން (seen)
ތިޔަބޭފުޅުންގެ AppDelegate ނުވަތަ SceneDelegate ގައި:
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
if let guid = userInfo["guid"] as? String {
// Report seen to SMSBAT
sendPushStatus(guid: guid, status: "seen")
}
completionHandler()
}
ނަތީޖާ
އިންޓެގްރޭޓް ކުރުމަށްފަހު އެޕަށް ނޮޓިފިކޭޝަންތައް ވަގުތުން ލިބި، ޕުޝް ލިބުމާއެކު ކެސްކޭޑް ހުއްޓި ފައިސާ ދެއްކޭ ޗެނަލްތަކުން ފައިސާ ނުނެގި، ތިޔަބޭފުޅުންނަށް ރަނގަޅު ފޮނުވި އަދި ކިޔުނު ހިސާބުތައް ލިބެއެވެ.
އެއްޗެއް ނުލިބޭނަމަ، ޕުޝް މައްސަލަ ހައްލުކުރުން ތެރެއިން ދާށެވެ — އެރަރެއް ނުފެންނަ ފެއިލްވުންތައް އެއީ ހިމެނޭ ގޮތުގައެވެ.