Skip to content

Commit

Permalink
fix Adaptive icon on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
van-tt committed Apr 23, 2022
1 parent 88f14a8 commit 50f7656
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 54 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"apply:android": "npx tsc configure/configure-android.ts && node configure/configure-android.js",
"apply:ios": "npx tsc configure/configure-ios.ts && node configure/configure-ios.js",
"env:custom": "npm run config -- --environment=development --awsUrl=https://aws.abcpay.cash/bws/api \n\n# Environment set to: dev\n\n",
"resources": "capacitor-resources -p android,ios",
"resources": "cordova-res android --copy && cp resources/android/ic_launcher.xml android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml && cp resources/android/ic_launcher_round.xml android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ",
"generate:android-bundle": "cd android && ./gradlew task && ./gradlew bundle",
"sign:android": "bundletool build-apks --mode=universal --bundle=./android/app/build/outputs/bundle/release/app-release.aab --output=./apks/apcpay-release.apks --ks=release.jks --ks-pass=pass:123456 --ks-key-alias=release --key-pass=pass:123456",
"final:android-release": "npm run build:android-release && rm -rf apks && npm run generate:android-bundle && npm run sign:android",
Expand All @@ -57,7 +57,7 @@
"@angular/router": "~13.1.1",
"@angular/service-worker": "^13.1.1",
"@bcpros/cordova-plugin-qrscanner": "^3.0.1",
"@capacitor/android": "3.3.3",
"@capacitor/android": "3.5.0",
"@capacitor/core": "^3.2.3",
"@capacitor/ios": "^3.2.3",
"@capacitor/project": "^1.0.28",
Expand Down Expand Up @@ -87,8 +87,6 @@
"base64-js": "^1.5.1",
"bitauth": "git+https://github.com/bitpay/bitauth.git#68cf0353bf517a7e5293478608839fa904351eb6",
"buffer-compare": "^1.1.1",
"capacitor-fcm": "^2.0.0",
"capacitor-resources": "^2.0.5",
"chart.js": "^3.5.1",
"cordova": "^10.0.0",
"cordova-android": "^10.1.0",
Expand All @@ -113,6 +111,7 @@
"cordova-plugin-whitelist": "^1.3.5",
"cordova-plugin-x-socialsharing": "^6.0.3",
"cordova-plugin-x-toast": "^2.7.2",
"cordova-res": "^0.15.4",
"countries-list": "^2.6.1",
"crypto-browserify": "^3.12.0",
"dotenv": "^10.0.0",
Expand Down
5 changes: 5 additions & 0 deletions resources/android/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions resources/android/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added resources/android/icon-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/android/icon-foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 50 additions & 50 deletions src/app/providers/push-notifications/push-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { timer } from 'rxjs';
import { FCM } from "capacitor-fcm";
// import { FCM } from "capacitor-fcm";
// providers
import { AppProvider } from '../app/app';
import { BwcProvider } from '../bwc/bwc';
Expand Down Expand Up @@ -35,7 +35,7 @@ export class PushNotificationsProvider {
private notifications = [];
private currentNotif: HTMLIonModalElement;
private openWalletId;
public fcm ;
// public fcm ;
constructor(
public http: HttpClient,
public profileProvider: ProfileProvider,
Expand All @@ -53,7 +53,7 @@ export class PushNotificationsProvider {
this.isIOS = this.platformProvider.isIOS;
this.isAndroid = this.platformProvider.isAndroid;
this.usePushNotifications = this.platformProvider.isCordova;
this.fcm = new FCM();
// this.fcm = new FCM();
}

public init(): void {
Expand All @@ -63,37 +63,37 @@ export class PushNotificationsProvider {
if (!config.pushNotifications.enabled) return;
await this.registerNotifications();
// On success, we should be able to receive notifications
this.fcm
.getToken()
.then(async token => {
if (!token) {
setTimeout(() => {
this.init();
}, 5000);
return;
}
this.logger.debug('Get token for push notifications: ' + token.token);
this._token = token.token;
this.enable();
// enabling topics
if (
this.appProvider.info.name != 'copay' &&
config.offersAndPromotions.enabled
)
await this.subscribeToTopic('offersandpromotions');
if (
this.appProvider.info.name != 'copay' &&
config.productsUpdates.enabled
)
await this.subscribeToTopic('productsupdates');

this.fcmInterval = setInterval(() => {
this.renewSubscription();
}, 5 * 60 * 1000); // 5 min

}).catch(error=>{
this.logger.error(error);
});
// this.fcm
// .getToken()
// .then(async token => {
// if (!token) {
// setTimeout(() => {
// this.init();
// }, 5000);
// return;
// }
// this.logger.debug('Get token for push notifications: ' + token.token);
// this._token = token.token;
// this.enable();
// // enabling topics
// if (
// this.appProvider.info.name != 'copay' &&
// config.offersAndPromotions.enabled
// )
// await this.subscribeToTopic('offersandpromotions');
// if (
// this.appProvider.info.name != 'copay' &&
// config.productsUpdates.enabled
// )
// await this.subscribeToTopic('productsupdates');
//
// this.fcmInterval = setInterval(() => {
// this.renewSubscription();
// }, 5 * 60 * 1000); // 5 min
//
// }).catch(error=>{
// this.logger.error(error);
// });
});

// Show us the notification payload if the app is open on our device
Expand Down Expand Up @@ -225,8 +225,8 @@ export class PushNotificationsProvider {
}

// disabling topics
this.unsubscribeFromTopic('offersandpromotions');
this.unsubscribeFromTopic('productsupdates');
// this.unsubscribeFromTopic('offersandpromotions');
// this.unsubscribeFromTopic('productsupdates');

const opts = {
showHidden: true
Expand All @@ -246,23 +246,23 @@ export class PushNotificationsProvider {
}

public async subscribeToTopic(topic: string): Promise<void> {
await this.fcm.subscribeTo({ topic: topic })
.then(r => {
return this.logger.info(r);
})
.catch(err => {
return this.logger.error(err);
});
// await this.fcm.subscribeTo({ topic: topic })
// .then(r => {
// return this.logger.info(r);
// })
// .catch(err => {
// return this.logger.error(err);
// });
}

public async unsubscribeFromTopic(topic: string): Promise<void> {
await this.fcm.unsubscribeFrom({ topic: topic })
.then(r => {
return this.logger.info(r);
})
.catch(err => {
return this.logger.error(err);
});
// await this.fcm.unsubscribeFrom({ topic: topic })
// .then(r => {
// return this.logger.info(r);
// })
// .catch(err => {
// return this.logger.error(err);
// });
}

private _subscribe(walletClient): void {
Expand Down

0 comments on commit 50f7656

Please sign in to comment.