Commit 30f6e216 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

firebase gcm ;

device utils module
parent 2a134b93
......@@ -163,6 +163,7 @@ dependencies {
//Firebase
implementation "com.google.firebase:firebase-analytics:$fireBaseVersion"
implementation 'com.google.firebase:firebase-messaging:20.1.3'
//CrshLytics
implementation "com.google.firebase:firebase-crashlytics:$firebaseCrashlyticsVersion"
......
......@@ -14,6 +14,14 @@
}
},
"oauth_client": [
{
"client_id": "740988198336-e2vel467jbici47mkokmmtuhg07gfl8k.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.biganto.visual.roompark",
"certificate_hash": "f23a8c722c050ddb5e6015b9f254535ddf5387ff"
}
},
{
"client_id": "740988198336-8c08r8mikgulg2s08p0fgi5j028rhn4u.apps.googleusercontent.com",
"client_type": 3
......
......@@ -3,17 +3,44 @@
package="com.biganto.visual.roompark">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".base.RoomParkApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:screenOrientation="userPortrait"
android:supportsRtl="true"
android:theme="@style/AppTheme.Launch">
<activity android:name=".base.RoomParkMainActivity"
<service
android:name=".data.RoomParkMessageService"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
<!--
Set custom default icon. This is used when no icon is set for incoming notification messages.
See README(https://goo.gl/l4GJaQ) for more.-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_bell_on" />
<!--
Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. See README(https://goo.gl/6BKBk7) for more.
-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
</service>
<activity
android:name=".base.RoomParkMainActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
......@@ -22,6 +49,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
......@@ -20,6 +20,7 @@ import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.textview.MaterialTextView
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.bell_switch_view.view.*
import kotlinx.android.synthetic.main.status_layout_toolbar.view.*
import kotlinx.android.synthetic.main.switch_toolbar.view.*
import timber.log.Timber
......@@ -105,7 +106,7 @@ class RoomParkMainActivity(
headerToolbarBack.text = it.backTitle?:""
headerToolbar.toolbar_title.text = it.title?:""
headerToolbar.subsciption_switcher.setGone(!(it.switcher?:false))
headerToolbar.bell_container.setGone(!(it.switcher?:false))
}
status?.let {
statusToolbar.status_icon.setGone(it.state == null)
......
package com.biganto.visual.roompark.data
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import timber.log.Timber
class RoomParkMessageService : FirebaseMessagingService() {
}
fun onMessageReceived(remoteMessage: RemoteMessage) { // ...
// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
Timber.d("From: ${remoteMessage.from}")
// Check if message contains a data payload.
if (remoteMessage.data.size > 0) {
Timber.d("Message data payload: %s", remoteMessage.data)
if ( /* Check if data needs to be processed by long running job */true) { // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
// scheduleJob()
} else { // Handle message within 10 seconds
// handleNow()
}
}
// Check if message contains a notification payload.
if (remoteMessage.notification != null) {
Timber.d("Message Notification Body: %s", remoteMessage.notification!!.body)
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
\ No newline at end of file
package com.biganto.visual.roompark.data.data_provider
import com.biganto.visual.roompark.domain.contract.DeviceUtilsContract
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.iid.FirebaseInstanceId
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 26.03.2020.
*/
class DeviceUtilsRepository @Inject constructor(
) : DeviceUtilsContract {
override fun getDeviceId(): Observable<String> =
Observable.create<String> {emitter ->
FirebaseInstanceId.getInstance().instanceId
.addOnCompleteListener(OnCompleteListener { task ->
if (!task.isSuccessful) {
Timber.w(task.exception, "getInstanceId failed")
emitter.onError(task.exception!!)
return@OnCompleteListener
}
// Get new Instance ID token
task.result?.token?.let { emitter.onNext(it) }
emitter.onComplete()
// Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show()
})
}.subscribeOn(Schedulers.computation())
}
\ No newline at end of file
......@@ -53,6 +53,7 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun filesRep(): FilesContract
fun subsRep(): SubscriptionContract
fun provideLocal():ILocalStore
......@@ -60,6 +61,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun providedb():IDb
fun provideUtils():DeviceUtilsContract
fun provideAppContext():Application
fun provideFileSystem(): FileModule
......
......@@ -38,9 +38,17 @@ abstract class ContractRepositoryModule {
@Singleton
abstract fun provideEstateContract(impl: EstateRepository): DealContract
@Binds
@Singleton
abstract fun provideSubscriptionsContract(impl: SubscriptionRepository): SubscriptionContract
@Binds
@Singleton
abstract fun provideFilesContract(impl: FilesContractModule): FilesContract
@Binds
@Singleton
abstract fun provideDeviceContract(impl: DeviceUtilsRepository): DeviceUtilsContract
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment