|
1 | | -### Intercom android module for Intercom Android SDK version 1.1.21 |
| 1 | +### Intercom android module for Intercom Android SDK version 1.1.20 |
2 | 2 |
|
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 |
4 | 4 |
|
5 | 5 | ### Example |
6 | 6 | ``` |
@@ -81,47 +81,70 @@ exports.setDeviceToken = function(token, appicon /* 'device-token', Ti.App.Andro |
81 | 81 | ### IMPORTANT : create hooks folder and intercom.js file in the module for Android GCM support |
82 | 82 | 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. |
83 | 83 |
|
84 | | -Create the following file: |
| 84 | +Create the following file if not already included in the distribution: |
85 | 85 |
|
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 |
87 | 87 | ``` |
88 | 88 | exports.cliVersion = '>=3.X'; |
89 | 89 |
|
90 | 90 | 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 | +
|
119 | 144 | } |
120 | | - }); |
121 | | - next(null, data); |
122 | | - } |
123 | | - }); |
| 145 | + }); |
124 | 146 | }; |
| 147 | +
|
125 | 148 | ``` |
126 | 149 |
|
127 | 150 |
|
|
0 commit comments