Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
d73d5e29
Commit
d73d5e29
authored
Jan 04, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement notifications support
parent
76425b8d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
20 deletions
+29
-20
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+17
-13
FirebaseTokenService.kt
...ain/java/chat/rocket/android/push/FirebaseTokenService.kt
+4
-2
GcmListenerService.kt
.../main/java/chat/rocket/android/push/GcmListenerService.kt
+3
-1
PushComponent.kt
...rc/main/java/chat/rocket/android/push/di/PushComponent.kt
+2
-2
PushModule.kt
app/src/main/java/chat/rocket/android/push/di/PushModule.kt
+2
-2
api_keys.xml
app/src/main/res/values/api_keys.xml
+1
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
d73d5e29
...
...
@@ -6,7 +6,9 @@
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"com.google.android.c2dm.permission.RECEIVE"
/>
<permission
android:name=
"chat.rocket.android.permission.C2D_MESSAGE"
android:protectionLevel=
"signature"
/>
<permission
android:name=
"chat.rocket.android.permission.C2D_MESSAGE"
android:protectionLevel=
"signature"
/>
<uses-permission
android:name=
"chat.rocket.android.permission.C2D_MESSAGE"
/>
...
...
@@ -39,31 +41,33 @@
<activity
android:name=
".app.ChatRoomActivity"
android:theme=
"@style/AppTheme"
>
</activity>
android:theme=
"@style/AppTheme"
></activity>
<receiver
android:name=
"com.google.android.gms.gcm.GcmReceiver"
android:exported=
"true"
android:permission=
"com.google.android.c2dm.permission.SEND"
>
android:permission=
"com.google.android.c2dm.permission.SEND"
>
<intent-filter>
<action
android:name=
"com.google.android.c2dm.intent.RECEIVE"
/>
<action
android:name=
"com.google.android.c2dm.intent.REGISTRATION"
/>
<category
android:name=
"chat.rocket.android"
/>
</intent-filter>
</receiver>
<
!--<service-->
<!--android:name=".push.TokenRotationService"-->
<!--android:exported="false">--
>
<
!--<intent-filter>--
>
<
!--<action android:name="com.google.android.gms.iid.InstanceID" />--
>
<
!--</intent-filter>--
>
<
!--</service>--
>
<
service
android:name=
".push.FirebaseTokenService"
android:exported=
"false"
>
<
intent-filter
>
<
action
android:name=
"com.google.firebase.INSTANCE_ID_EVENT"
/
>
<
/intent-filter
>
<
/service
>
<service
android:name=
".push.PushTokenService"
android:exported=
"true"
>
<service
android:name=
".push.GcmListenerService"
android:exported=
"false"
>
<intent-filter>
<action
android:name=
"com.google.
firebase.INSTANCE_ID_EVENT"
/>
<action
android:name=
"com.google.
android.c2dm.intent.RECEIVE"
/>
</intent-filter>
</service>
...
...
app/src/main/java/chat/rocket/android/push/FirebaseTokenService.kt
View file @
d73d5e29
...
...
@@ -15,7 +15,7 @@ import kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
javax.inject.Inject
class
Push
TokenService
:
FirebaseInstanceIdService
()
{
class
Firebase
TokenService
:
FirebaseInstanceIdService
()
{
@Inject
lateinit
var
client
:
RocketChatClient
...
...
@@ -34,8 +34,10 @@ class PushTokenService : FirebaseInstanceIdService() {
override
fun
onTokenRefresh
()
{
//TODO: We need to use the Cordova Project gcm_sender_id since it's the one configured on RC
// default push gateway. We should register this project's own project sender id into it.
val
gcmToken
=
InstanceID
.
getInstance
(
this
)
.
getToken
(
getString
(
R
.
string
.
gcm_
defaultSenderId
,
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
)
,
null
)
.
getToken
(
getString
(
R
.
string
.
gcm_
sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
gcmToken
?.
let
{
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
gcmToken
)
...
...
app/src/main/java/chat/rocket/android/push/GcmListenerService.kt
View file @
d73d5e29
...
...
@@ -6,6 +6,8 @@ import com.google.android.gms.gcm.GcmListenerService
class
GcmListenerService
:
GcmListenerService
()
{
override
fun
onMessageReceived
(
from
:
String
?,
data
:
Bundle
?)
{
println
(
"UBA BA!"
)
data
?.
let
{
PushManager
.
handle
(
this
,
data
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/di/PushComponent.kt
View file @
d73d5e29
package
chat.rocket.android.push.di
import
chat.rocket.android.dagger.module.AppModule
import
chat.rocket.android.push.
Push
TokenService
import
chat.rocket.android.push.
Firebase
TokenService
import
dagger.Component
import
javax.inject.Singleton
@Singleton
@Component
(
modules
=
arrayOf
(
AppModule
::
class
,
PushModule
::
class
))
interface
PushComponent
{
fun
inject
(
service
:
Push
TokenService
)
fun
inject
(
service
:
Firebase
TokenService
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/di/PushModule.kt
View file @
d73d5e29
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.push.di
import
chat.rocket.android.authentication.infraestructure.AuthTokenRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.SharedPreferencesRepository
import
chat.rocket.android.push.
Push
TokenService
import
chat.rocket.android.push.
Firebase
TokenService
import
chat.rocket.common.util.PlatformLogger
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.TokenRepository
...
...
@@ -15,7 +15,7 @@ import javax.inject.Singleton
@Module
@Singleton
class
PushModule
(
val
context
:
Push
TokenService
)
{
class
PushModule
(
val
context
:
Firebase
TokenService
)
{
@Provides
fun
provideAuthTokenRepository
():
TokenRepository
=
AuthTokenRepository
()
...
...
app/src/main/res/values/api_keys.xml
View file @
d73d5e29
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- This is the Cordova GCM sender id-->
<string
name=
"gcm_sender_id"
>
673693445664
</string>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment