From c7d0fb1ad792b51c7f00740b1d343b1598e453d5 Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Sat, 16 Dec 2023 23:06:43 -0600 Subject: [PATCH] ok everything works now --- .../main/java/io/heckel/ntfy/service/SubscriberService.kt | 5 ++--- app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt index f68f38f..ff3a64c 100644 --- a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt +++ b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt @@ -257,10 +257,9 @@ class SubscriberService : Service() { GlobalScope.launch(Dispatchers.IO) { for (topic in connectionId.topicsToSubscriptionIds.keys) { if (connectionId.topicIsUnifiedPush[topic] == true) { - io.heckel.ntfy.up.BroadcastReceiver.sendRegistration(baseContext, connectionId.baseUrl, topic) - // TODO is that the right context - // looks like it works??? Log.d(TAG, "Attempting to re-register ${connectionId.baseUrl}/$topic") + io.heckel.ntfy.up.BroadcastReceiver.sendRegistration(baseContext, connectionId.baseUrl, topic) + // TODO is that the right context - looks like it works??? } } } diff --git a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt index 34c8fc7..1b86cd7 100644 --- a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +++ b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt @@ -97,7 +97,8 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { registering with the push server. This avoids a race condition where the application server is rejected before ntfy even establishes that this topic exists. This is fine from an application perspective, because other distributors can't even register - without a connection to the push server. */ + without a connection to the push server. + Unless the app sends registration twice. Then it'll get the endpoint.*/ //Refresh (and maybe start) foreground service SubscriberServiceManager.refresh(app) @@ -164,7 +165,6 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { val appId = existingSubscription.upAppId ?: return@launch val connectorToken = existingSubscription.upConnectorToken ?: return@launch val endpoint = topicUrlUp(existingSubscription.baseUrl, existingSubscription.topic) - Log.d(TAG, "Sending endpoint $endpoint to ${existingSubscription.upAppId}") distributor.sendEndpoint(appId, connectorToken, endpoint) } }