Skip to content

Commit 82a4c78

Browse files
committed
Resolved missing icon on push notifications and added auto path finding in the module hook
1 parent 4594368 commit 82a4c78

7 files changed

Lines changed: 61 additions & 38 deletions

README.md

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
### Intercom android module for Intercom Android SDK version 1.1.21
1+
### Intercom android module for Intercom Android SDK version 1.1.20
22

3-
Integrate Intercom.io with Appcelerator. iOS module available here https://github.com/markive/TiIntercom . Tested with 5.1.1GA SDK
3+
Integrate Intercom.io with Appcelerator. iOS module available here https://github.com/markive/TiIntercom . Tested with Alloy and 5.1.1GA SDK
44

55
### Example
66
```
@@ -81,47 +81,70 @@ exports.setDeviceToken = function(token, appicon /* 'device-token', Ti.App.Andro
8181
### IMPORTANT : create hooks folder and intercom.js file in the module for Android GCM support
8282
You need to create a hooks folder with a .js file inside the module directory with the following contents. This makes sure the additional R values are added for intercom during compile. If someone can tell me how to update the ant build script to create this automatically in the compiled dist please let me know otherwise you need to do this manually after compile.
8383

84-
Create the following file:
84+
Create the following file if not already included in the distribution:
8585

86-
FILE: /modules/android/ti.intercom.android/1.0.4/hooks/intercom.js
86+
FILE: /modules/android/ti.intercom.android/XX.XX.XX/hooks/intercom.js
8787
```
8888
exports.cliVersion = '>=3.X';
8989
9090
exports.init = function(logger, config, cli, appc) {
91-
cli.on('build.android.aapt', {
92-
pre : function(data, next) {
93-
var args = data.args[1];
94-
if (args.indexOf('--auto-add-overlay') < 0) {
95-
args.push('--auto-add-overlay');
96-
}
97-
98-
var externalLibraries = [{
99-
javaClass : 'io.intercom.android.sdk.gcm',
100-
resPath : '/Users/jerodfritz/Appcelerator/Prspctr/modules/android/ti.intercom.android/1.0.4/platform/android/gcm-res'
101-
}];
102-
console.log("Add Intercom GCM External Libraries", JSON.stringify(externalLibraries));
103-
104-
// --extra-packages can be defined just once
105-
if (args.indexOf('--extra-packages') < 0) {
106-
args.push('--extra-packages');
107-
args.push('');
108-
}
109-
var namespaceIndex = args.indexOf('--extra-packages') + 1;
110-
111-
externalLibraries.forEach(function(lib) {
112-
if (args[namespaceIndex].indexOf(lib.javaClass) < 0) {
113-
args[namespaceIndex].length && (args[namespaceIndex] += ':');
114-
args[namespaceIndex] += lib.javaClass;
115-
}
116-
if (args.indexOf(lib.resPath) < 0) {
117-
args.push('-S');
118-
args.push(lib.resPath);
91+
cli.on('build.android.aapt', {
92+
pre: function(data, next) {
93+
var args = data.args[1],
94+
i18n = appc.i18n(__dirname),
95+
__ = i18n.__,
96+
path = require('path'),
97+
appDir = path.join(cli.argv['project-dir'], 'app'),
98+
find = function(items, f) {
99+
for (var i = 0; i < items.length; i++) {
100+
var item = items[i];
101+
if (f(item)) return item;
102+
};
103+
},
104+
module = false;
105+
if (args.indexOf('--auto-add-overlay') < 0) {
106+
args.push('--auto-add-overlay');
107+
}
108+
for(var i in cli.tiapp.modules) {
109+
if (cli.tiapp.modules[i].id == "ti.intercom.android") {
110+
module = cli.tiapp.modules[i];
111+
break;
112+
}
113+
}
114+
if (!module) {
115+
logger.error(__('Unable to determine Android Intercom module version. You must specify the module version specfically in your tiapp.xml'));
116+
process.exit(1);
117+
} else {
118+
var externalLibraries = [{
119+
javaClass: 'io.intercom.android.sdk.gcm',
120+
resPath: appDir + '/../modules/android/ti.intercom.android/' + module.version + '/platform/android/gcm-res'
121+
}];
122+
logger.info(__("Add Intercom GCM External Libraries" + JSON.stringify(externalLibraries)));
123+
124+
// --extra-packages can be defined just once
125+
if (args.indexOf('--extra-packages') < 0) {
126+
args.push('--extra-packages');
127+
args.push('');
128+
}
129+
var namespaceIndex = args.indexOf('--extra-packages') + 1;
130+
131+
externalLibraries.forEach(function(lib) {
132+
if (args[namespaceIndex].indexOf(lib.javaClass) < 0) {
133+
args[namespaceIndex].length && (args[namespaceIndex] += ':');
134+
args[namespaceIndex] += lib.javaClass;
135+
}
136+
if (args.indexOf(lib.resPath) < 0) {
137+
args.push('-S');
138+
args.push(lib.resPath);
139+
}
140+
});
141+
next(null, data);
142+
}
143+
119144
}
120-
});
121-
next(null, data);
122-
}
123-
});
145+
});
124146
};
147+
125148
```
126149

127150

1.91 MB
Binary file not shown.

android/dist/tiintercomandroid.jar

0 Bytes
Binary file not shown.
1 Byte
Binary file not shown.
-79 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

android/manifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# this is your module manifest and used by Titanium
33
# during compilation, packaging, distribution, etc.
44
#
5-
version: 1.0.4
5+
version: 1.0.5
66
apiversion: 2
77
architectures: armeabi armeabi-v7a x86
88
description: tiintercomandroid
99
author: Jerod Fritz
1010
license: Specify your license
1111
copyright: Copyright (c) 2015 by Your Company
12-
respackage: io.intercom.android.sdk
12+
respackage: io.intercom.android.sdk
1313

1414
# these should not be edited
1515
name: tiintercomandroid

0 commit comments

Comments
 (0)