Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unified Push support #715

Open
wants to merge 6 commits into
base: master10-2-6
Choose a base branch
from

Conversation

drizzt
Copy link

@drizzt drizzt commented Dec 10, 2023

This simple implementation only triggers the networks to resume when an
event is received, so Telegram can get the events by itself.

This is not like the other push providers where the change information
is processed by PushListenerController directly, but it still saves battery
since the process disconnects from Telegram servers as soon as the
updates are processed.

I also reverted "[TF][PUSH] remove one of the confusing toggles", since with UnifiedPush it's worthless to enable the pushService when UnifiedPush is used.

It fixes #577

@drizzt drizzt changed the title Add Unified Push support Add Unified Push support #577 Dec 10, 2023
@drizzt drizzt changed the title Add Unified Push support #577 Add Unified Push support Dec 10, 2023
@drizzt drizzt mentioned this pull request Dec 10, 2023
This reverts the NotificationsSettingsActivity.java part of commit
53a4963.
@drizzt drizzt force-pushed the UnifiedPush branch 3 times, most recently from 1b67551 to b8eac92 Compare December 11, 2023 03:39
@warioishere
Copy link

@drizzt
hi drizzt, been follwing this since you came up with the fork, nice work, we are happy seeing this on Telegram
Just got some issues here and dont know where to post, as i dont find an issue area for mercurygram.
I just wanted to say that your first fork (telegram-foss-unified-push) worked well. then i switched to the new updated with rebanding to mercurygram.
Push doesnt work anymore on our own ntfy-server. If i can help you in anyway let me know, although im not a programmer

Greetings

@drizzt drizzt marked this pull request as draft December 11, 2023 13:00
This simple implementation only triggers the networks to resume when an
event is received, so Telegram can get the events by itself.

This is not like the other push providers where the change information
is processed by PushListenerController directly, but it still saves battery
since the process disconnects from Telegram servers as soon as the
updates are processed.
@drizzt
Copy link
Author

drizzt commented Dec 11, 2023

Due to android limitations the battery optimization should be turn off, but you don't have battery usage if you turn off keep alive and background tasks.

@drizzt drizzt marked this pull request as ready for review December 11, 2023 23:29
@drizzt drizzt requested a review from p1gp1g December 11, 2023 23:29
@drizzt
Copy link
Author

drizzt commented Dec 12, 2023

if you agree with my objections I'll change the 3 remaining stuff and thank you for the review

@drizzt drizzt requested a review from p1gp1g December 12, 2023 11:24
@thermatk thermatk changed the base branch from master to master10-2-6 December 13, 2023 14:06
@thermatk
Copy link
Member

looks awesome. Sorry for not writing sooner or reviewing, I'm caught in a personal situation. I have switched base to non-master so that it is still clean and I can release update on master asap, while this can be tackled in a slow manner :)

<action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED"/>
</intent-filter>
</receiver>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only need to add this to TMessagesProj/src/main/AndroidManifest.xml, all these manifest changes are not needed.

Timothy Redaelli added 3 commits December 26, 2023 11:49
Since android-connector is built with Java 17 some other build system
modifications were needed.

This also means ./gradlew must be called using Java 17+.
@p1gp1g
Copy link

p1gp1g commented Dec 27, 2023

android-connector:2.3.0 uses jvmToolchain, it should work with java 1.8. You may have to add this to your build.gradle

kotlin {
    jvmToolchain(8)
}

@drizzt
Copy link
Author

drizzt commented Dec 27, 2023

android-connector:2.3.0 uses jvmToolchain, it should work with java 1.8. You may have to add this to your build.gradle

kotlin {
    jvmToolchain(8)
}

I tried to do that, but it still needs a newer java:

Task :TMessagesProj:compileReleaseJavaWithJavac
/home/tredaell/dev/sources/Mercurygram/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushReceiver.java:9: error: cannot access MessagingReceiver
import org.unifiedpush.android.connector.MessagingReceiver;
^
bad class file: /home/tredaell/.gradle/caches/transforms-3/d89406eb52297902fd6a4f25745d4ff1/transformed/jetified-android-connector-2.3.0-api.jar(/org/unifiedpush/android/connector/MessagingReceiver.class)
class file has wrong version 61.0, should be 55.0

@p1gp1g
Copy link

p1gp1g commented Dec 28, 2023

Indeed, it seems you need gradle 8+

EDIT: with android-connector:2.4.0, you shouldn't have to upgrade gradle either.

diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle
index 5f733bef..edff97a0 100644
--- a/TMessagesProj/build.gradle
+++ b/TMessagesProj/build.gradle
@@ -39,7 +39,7 @@ dependencies {
     implementation 'com.google.code.gson:gson:2.10'
     implementation 'com.google.guava:guava:31.1-android'
 
-    implementation 'com.github.UnifiedPush:android-connector:2.2.0'
+    implementation 'com.github.UnifiedPush:android-connector:2.3.1'
 
     implementation 'org.osmdroid:osmdroid-android:6.1.14'
 
@@ -84,8 +84,8 @@ android {
     }
 
     compileOptions {
-        sourceCompatibility JavaVersion.VERSION_17
-        targetCompatibility JavaVersion.VERSION_17
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
 
         coreLibraryDesugaringEnabled true
     }
@@ -193,6 +193,8 @@ android {
             buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
         }
     }
+
+    namespace = "org.telegram.messenger"
 }
 
 
diff --git a/TMessagesProj_App/build.gradle b/TMessagesProj_App/build.gradle
index 7c2b7305..7d762e9e 100644
--- a/TMessagesProj_App/build.gradle
+++ b/TMessagesProj_App/build.gradle
@@ -44,8 +44,8 @@ android {
     }
 
     compileOptions {
-        sourceCompatibility JavaVersion.VERSION_17
-        targetCompatibility JavaVersion.VERSION_17
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
 
         coreLibraryDesugaringEnabled true
     }
@@ -181,4 +181,6 @@ android {
     lintOptions {
         checkReleaseBuilds false
     }
+
+    namespace = "org.telegram.messenger.regular"
 }
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index f48ee03c..addb3b69 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,9 +5,7 @@ buildscript {
         google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:7.0.3'
-        // This is needed since android-connector:2.2.0 is built with Java 17
-        classpath 'com.android.tools:r8:8.2.33'
+        classpath 'com.android.tools.build:gradle:8.2.0'
     }
 }
 repositories {
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ffed3a25..b26d0324 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Thu Dec 28 14:56:03 CET 2023
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists

@p1gp1g
Copy link

p1gp1g commented Jan 18, 2024

You shouldn't even have to upgrade gradle with connector:2.4.0.

@opusforlife2
Copy link

Hi. I've read the thread above, but it's not clear if this PR is blocked by something else in order to progress. Is that the case?

@Integral-Tech
Copy link

Any progress on this PR?

@ildar
Copy link

ildar commented Sep 9, 2024 via email

@warioishere
Copy link

it works, but sometimes notifications are heavily delayed. Using Mercurygram latest and own ntfy server and ntfy client on android

Can anyone confirm it works? I still find it hard to believe it does.

@ildar
Copy link

ildar commented Sep 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push notifications
8 participants