У меня есть проблема, чтобы изменить маленький значок push-уведомления. Onesignal в ionic 3, я пробовал этот урок https://documentation.onesignal.com/docs/customize-notification-icons, https://ionicframework.com/docs/native/onesignal/ и https://github.com/OneSignal/OneSignal-Cordova-SDK/issues/341#issuecomment-382648188,, но потерпел неудачу, маленький значок в моемpush-уведомление по-прежнему по умолчанию имеет значение onesignal.
Это структура моей папки и мой сценарий:
Структура моей папки :
copy_android_notification_icons.js :
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var rootDest = 'platforms/android/app/src/main/res';
var files = [{
'icon_onesignal/res/drawable-hdpi/ic_stat_onesignal_default.png':
path.join(rootDest, 'drawable-hdpi/ic_stat_onesignal_default.png')
}, {
'icon_onesignal/res/drawable-mdpi/ic_stat_onesignal_default.png':
path.join(rootDest, 'drawable-mdpi/ic_stat_onesignal_default.png')
}, {
'icon_onesignal/res/drawable-xhdpi/ic_stat_onesignal_default.png':
path.join(rootDest, 'drawable-xhdpi/ic_stat_onesignal_default.png')
}, {
'icon_onesignal/res/drawable-xxhdpi/ic_stat_onesignal_default.png':
path.join(rootDest, 'drawable-xxhdpi/ic_stat_onesignal_default.png')
}, {
'icon_onesignal/res/drawable-xxxhdpi/ic_stat_onesignal_default.png':
path.join(rootDest, 'drawable-xxxhdpi/ic_stat_onesignal_default.png')
}];
function createFolder(pathAbsolute) {
if (!fs.existsSync(pathAbsolute)) {
fs.mkdirSync(pathAbsolute);
}
console.log('Folder ready ', pathAbsolute);
}
module.exports = function(context) {
var root = context.opts.projectRoot;
createFolder(path.join(root, rootDest, 'drawable-hdpi'));
createFolder(path.join(root, rootDest, 'drawable-mdpi'));
createFolder(path.join(root, rootDest, 'drawable-xhdpi'));
createFolder(path.join(root, rootDest, 'drawable-xxhdpi'));
createFolder(path.join(root, rootDest, 'drawable-xxxhdpi'));
files.forEach(function(obj) {
Object.keys(obj).forEach(function(key) {
var src = path.join(root, key);
var dest = path.join(root, obj[key]);
if (fs.existsSync(src) && fs.existsSync(path.dirname(dest))) {
fs.createReadStream(src).pipe(fs.createWriteStream(dest));
console.log('Copied ' + src + ' to ' + dest);
}
});
});
};
app.components.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window["plugins"].OneSignal
.startInit("xxxx-yyyy-zzzz-123, "1234567")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
});
}
}
config.xml
<platform name="android">
<allow-intent href="market:*" />
<hook src="hooks/copy_android_notification_icons.js" type="after_prepare" />
</platform>
Пожалуйста, исправьте мою папку или мой скрипт, возможно, вы найдете ошибку и, пожалуйста, помогите решить эту проблему.
Спасибо.