@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
55Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
66exports . withIntercomMainApplication = exports . withIntercomAppBuildGradle = exports . withIntercomAndroidManifest = exports . withIntercomAndroid = void 0 ;
77const config_plugins_1 = require ( "@expo/config-plugins" ) ;
8- const generateCode_1 = require ( "@expo/config-plugins/build/utils/generateCode" ) ;
98const image_utils_1 = require ( "@expo/image-utils" ) ;
109const fs_1 = require ( "fs" ) ;
1110const path_1 = __importDefault ( require ( "path" ) ) ;
@@ -35,24 +34,22 @@ async function saveFileAsync(path, content) {
3534}
3635function getMainNotificationService ( packageName ) {
3736 return `package ${ packageName } ;
38- import expo.modules.notifications.service.ExpoFirebaseMessagingService ;
37+ import com.google.firebase.messaging.FirebaseMessagingService ;
3938import com.google.firebase.messaging.RemoteMessage;
4039import com.intercom.reactnative.IntercomModule;
4140
42- public class MainNotificationService extends ExpoFirebaseMessagingService {
4341
44- @Override
45- public void onNewToken(String refreshedToken) {
42+ public class MainNotificationService extends FirebaseMessagingService {
43+
44+ @Override public void onNewToken(String refreshedToken) {
4645 IntercomModule.sendTokenToIntercom(getApplication(), refreshedToken);
47- super.onNewToken(refreshedToken);
4846 }
4947
50- @Override
5148 public void onMessageReceived(RemoteMessage remoteMessage) {
5249 if (IntercomModule.isIntercomPush(remoteMessage)) {
5350 IntercomModule.handleRemotePushMessage(getApplication(), remoteMessage);
5451 } else {
55- super.onMessageReceived(remoteMessage);
52+ // HANDLE NON-INTERCOM MESSAGE
5653 }
5754 }
5855}` ;
@@ -134,8 +131,8 @@ const withIntercomAndroidManifest = (config, { EURegion, pushNotifications }) =>
134131exports . withIntercomAndroidManifest = withIntercomAndroidManifest ;
135132const withIntercomProjectBuildGradle = ( config ) => {
136133 return ( 0 , config_plugins_1 . withProjectBuildGradle ) ( config , async ( config ) => {
137- const googleClasspath = `classpath 'com.google.gms:google-services:4.3.15 '` ;
138- if ( ! config . modResults . contents . includes ( googleClasspath ) ) {
134+ const googleClasspath = `classpath 'com.google.gms:google-services:4.2.0 '` ;
135+ if ( ! config . modResults . contents . includes ( 'com.google.gms:google-services' ) ) {
139136 const anchor = `dependencies {` ;
140137 config . modResults . contents = config . modResults . contents . replace ( `${ anchor } ` , `${ anchor } \n\t\t${ googleClasspath } ` ) ;
141138 }
@@ -144,18 +141,10 @@ const withIntercomProjectBuildGradle = (config) => {
144141} ;
145142const withIntercomAppBuildGradle = ( config , { pushNotifications } ) => {
146143 return ( 0 , config_plugins_1 . withAppBuildGradle ) ( config , async ( config ) => {
147- config . modResults . contents = ( 0 , generateCode_1 . mergeContents ) ( {
148- tag : "okhttp-urlconnection" ,
149- src : config . modResults . contents ,
150- newSrc : " implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.10.+'" ,
151- anchor : / d e p e n d e n c i e s \s * \{ / ,
152- offset : 1 ,
153- comment : "//" ,
154- } ) . contents ;
155144 if ( pushNotifications ) {
156- const firebaseImp = `implementation 'com.google.firebase:firebase-messaging:23.1 .+'` ;
145+ const firebaseImp = `implementation 'com.google.firebase:firebase-messaging:20.2 .+'` ;
157146 if ( ! config . modResults . contents . includes ( firebaseImp ) ) {
158- const anchor = `implementation "com.facebook.react:react-native:+" // From node_modules ` ;
147+ const anchor = `implementation( "com.facebook.react:react-android") ` ;
159148 config . modResults . contents = config . modResults . contents . replace ( anchor , `${ anchor }
160149 ${ firebaseImp } ` ) ;
161150 }
@@ -209,14 +198,14 @@ const modifyMainApplication = ({ contents, apiKey, appId, packageName, }) => {
209198 }
210199 const importLine = `import com.intercom.reactnative.IntercomModule;` ;
211200 if ( ! contents . includes ( importLine ) ) {
212- const packageImport = `package ${ packageName } ; ` ;
201+ const packageImport = `package ${ packageName } ` ;
213202 // Add the import line to the top of the file
214203 // Replace the first line with the intercom import
215- contents = contents . replace ( `${ packageImport } ` , `${ packageImport } \n${ importLine } ` ) ;
204+ contents = contents . replace ( `${ packageImport } ` , `${ packageImport } \n\n ${ importLine } ` ) ;
216205 }
217206 const initLine = `IntercomModule.initialize(this, "${ apiKey } ", "${ appId } ");` ;
218207 if ( ! contents . includes ( initLine ) ) {
219- const soLoaderLine = `SoLoader.init(this, /* native exopackage */ false); ` ;
208+ const soLoaderLine = `SoLoader.init(this, false)` ;
220209 // Replace the line SoLoader.init(this, /* native exopackage */ false); with regex
221210 contents = contents . replace ( `${ soLoaderLine } ` , `${ soLoaderLine } \n\t\t${ initLine } \n` ) ;
222211 }
0 commit comments