Skip to content

Commit

Permalink
THE NEEDED CHANGES
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Jan 3, 2021
1 parent ed8c3ab commit 6e5e20e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}

android {
Expand Down Expand Up @@ -41,6 +42,7 @@ dependencies {
implementation 'com.android.volley:dc-volley:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.github.UnifiedPush:UP-lib:332bcdd07b'
implementation 'com.github.UnifiedPush:UP-lib_fcm-added:a810b2f7f5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand Down
39 changes: 39 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "64518491375",
"project_id": "unifiedpush-3f07b",
"storage_bucket": "unifiedpush-3f07b.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:64518491375:android:839eaf67570270e2b69f1a",
"android_client_info": {
"package_name": "org.unifiedpush.example"
}
},
"oauth_client": [
{
"client_id": "64518491375-f8ds3h419jcbesmform13mdl2kcg0ois.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBVSqffMY71m_Jp1chpq4FpZdQ1UTtU4a0"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "64518491375-f8ds3h419jcbesmform13mdl2kcg0ois.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
<action android:name="org.unifiedpush.android.connector.NEW_ENDPOINT"/>
<action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED" />
<action android:name="org.unifiedpush.android.connector.REGISTRATION_REFUSED" />
<action android:name="org.unifiedpush.android.distributor.REGISTER"/>
<action android:name="org.unifiedpush.android.distributor.UNREGISTER"/>
</intent-filter>
</receiver>
</application>

</manifest>
</manifest>
6 changes: 3 additions & 3 deletions app/src/main/java/org/unifiedpush/example/CheckActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import com.android.volley.RequestQueue
import com.android.volley.Response
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley
import org.unifiedpush.android.connector.*
import org.unifiedpush.android.connector_fcm_added.*

const val UPDATE = "org.unifiedpush.example.android.action.UPDATE"

class CheckActivity : Activity() {

private var endpoint = ""
private val up = Registration()
private val up = RegistrationFCM()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -86,4 +86,4 @@ class CheckActivity : Activity() {
}
requestQueue.add(stringRequest)
}
}
}
12 changes: 8 additions & 4 deletions app/src/main/java/org/unifiedpush/example/CustomReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package org.unifiedpush.example
import android.content.Context
import android.content.Intent
import android.widget.Toast
import org.unifiedpush.android.connector.MessagingReceiver
import org.unifiedpush.android.connector.MessagingReceiverHandler
import org.unifiedpush.android.connector_fcm_added.MessagingReceiverFCM
import org.unifiedpush.android.connector_fcm_added.MessagingReceiverHandlerFCM
import java.net.URLDecoder

val handler = object: MessagingReceiverHandler{
val handler = object: MessagingReceiverHandlerFCM{
override fun onMessage(context: Context?, message: String) {
val dict = URLDecoder.decode(message,"UTF-8").split("&")
val params= dict.associate { try{it.split("=")[0] to it.split("=")[1]}catch (e: Exception){"" to ""} }
Expand Down Expand Up @@ -42,6 +42,10 @@ val handler = object: MessagingReceiverHandler{
broadcastIntent.putExtra("registered", "false")
context.sendBroadcast(broadcastIntent)
}

override fun getEndpoint(token: String): String {
return "https://fcm.example.unifiedpush.org/FCM?token=$token"
}
}

class CustomReceiver: MessagingReceiver(handler)
class CustomReceiver: MessagingReceiverFCM(handler)
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 6e5e20e

Please sign in to comment.