Skip to content

Commit 00c6ed8

Browse files
authored
Merge pull request #51 from hansemannn/update-play-services
feat(android): update firebase to latest
2 parents 502fd4b + 0b1957b commit 00c6ed8

File tree

8 files changed

+25
-44
lines changed

8 files changed

+25
-44
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repositories {
77
}
88

99
dependencies {
10-
compile 'com.google.firebase:firebase-messaging:11.0.4'
10+
compile 'com.google.firebase:firebase-messaging:17.5.0'
1111
}
1212

1313
configurations.all {
-24.2 KB
Binary file not shown.
71 KB
Binary file not shown.

android/manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# this is your module manifest and used by Titanium
33
# during compilation, packaging, distribution, etc.
44
#
5-
version: 1.5.0
5+
version: 2.0.0
66
apiversion: 4
77
architectures: arm64-v8a armeabi-v7a x86
88
description: titanium-firebase-cloud-messaging

android/src/firebase/cloudmessaging/CloudMessagingModule.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
import com.google.firebase.iid.FirebaseInstanceId;
3232
import com.google.firebase.messaging.FirebaseMessaging;
3333
import com.google.firebase.messaging.RemoteMessage;
34+
import com.google.firebase.iid.InstanceIdResult;
35+
import com.google.android.gms.tasks.OnSuccessListener;
3436
import org.appcelerator.kroll.KrollDict;
35-
import org.appcelerator.kroll.common.Log;
3637
import java.util.HashMap;
3738
import org.appcelerator.kroll.KrollFunction;
3839
import java.util.Map;
39-
import android.content.Intent;
4040
import org.json.JSONObject;
4141
import ti.modules.titanium.android.notificationmanager.NotificationChannelProxy;
4242

@@ -97,7 +97,15 @@ private KrollDict getLastData()
9797
@Kroll.method
9898
public void registerForPushNotifications()
9999
{
100-
FirebaseInstanceId.getInstance().getToken();
100+
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(
101+
TiApplication.getAppRootOrCurrentActivity(), new OnSuccessListener<InstanceIdResult>() {
102+
@Override
103+
public void onSuccess(InstanceIdResult instanceIdResult)
104+
{
105+
String newToken = instanceIdResult.getToken();
106+
onTokenRefresh(newToken);
107+
}
108+
});
101109
parseBootIntent();
102110
}
103111

android/src/firebase/cloudmessaging/TiFirebaseInstanceIDService.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

android/src/firebase/cloudmessaging/TiFirebaseMessagingService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ public class TiFirebaseMessagingService extends FirebaseMessagingService
3434
private static final String TAG = "FirebaseMsgService";
3535
private static final AtomicInteger atomic = new AtomicInteger(0);
3636

37+
@Override
38+
public void onNewToken(String s) {
39+
super.onNewToken(s);
40+
CloudMessagingModule module = CloudMessagingModule.getInstance();
41+
if (module != null) {
42+
module.onTokenRefresh(s);
43+
}
44+
Log.d(TAG, "New token: " + s);
45+
}
46+
3747
@Override
3848
public void onMessageSent(String msgID)
3949
{

android/timodule.xml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,11 @@
66
<uses-permission android:name="android.permission.WAKE_LOCK"/>
77
<uses-permission android:name="android.permission.VIBRATE"/>
88
<application>
9-
<service android:name="firebase.cloudmessaging.TiFirebaseMessagingService" android:exported="false">
9+
<service android:name="firebase.cloudmessaging.TiFirebaseMessagingService" >
1010
<intent-filter>
1111
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
1212
</intent-filter>
1313
</service>
14-
<service android:name="firebase.cloudmessaging.TiFirebaseInstanceIDService" android:exported="false">
15-
<intent-filter>
16-
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
17-
</intent-filter>
18-
</service>
19-
20-
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false"/>
21-
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
22-
<intent-filter>
23-
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
24-
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
25-
<category android:name="${tiapp.properties['id']}"/>
26-
</intent-filter>
27-
</receiver>
28-
2914
<activity android:name="firebase.cloudmessaging.PushHandlerActivity" android:exported="true"></activity>
3015
</application>
3116
</manifest>
@@ -35,6 +20,6 @@
3520
<module>firebase.core</module>
3621

3722
<!-- Require Ti.PlayServices (https://github.com/appcelerator-modules/ti.playservices) -->
38-
<module platform="android" version="11.0.40">ti.playservices</module>
23+
<module platform="android" version="16.1.2">ti.playservices</module>
3924
</modules>
4025
</ti:module>

0 commit comments

Comments
 (0)