-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UrbanAirship on android : unable to find google-services.json & No matching client found for package name 'capacitor.android.plugins' #2511
Comments
Alright ! seems that adding
into the I get the notification in background while the app is open, but not while it's closed. But it may be something else not related. To anyone coming here, here is my ReactJS code to make it work. You'll see that you still need I've also followed all the integration of push notification tutorial for iOS apps in capacitor with firebase to make it work for the iPhones. import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar, useIonViewDidEnter } from '@ionic/react';
import React from 'react';
import ExploreContainer from '../components/ExploreContainer';
import { UrbanAirShip } from '@ionic-native/urbanairship';
import './Home.css';
import {
Plugins,
PushNotification,
PushNotificationToken,
PushNotificationActionPerformed } from '@capacitor/core';
const { PushNotifications } = Plugins;
PushNotifications.register();
async function registerNotification() {
try {
await UrbanAirShip.takeOff({
development: {
appKey: "xxx",
appSecret: "xxxx"
},
production: {
appKey: "", // needed, even if empty
appSecret: "" // needed, even if empty
}
})
await UrbanAirShip.setUserNotificationsEnabled(true)
const isEnabled = await UrbanAirShip.isUserNotificationsEnabled();
const isAppEnabled = await UrbanAirShip.isAppNotificationsEnabled();
const channelId = await UrbanAirShip.getChannelID();
console.log('isEnabled', isEnabled, isAppEnabled);
console.log('channelId', channelId);
PushNotifications.addListener('registration',
(token: PushNotificationToken) => {
console.log('Push registration success, token: ' + token.value);
}
);
// Some issue with our setup and push will not work
PushNotifications.addListener('registrationError',
(error: any) => {
console.log('Error on registration: ' + JSON.stringify(error));
}
);
// Show us the notification payload if the app is open on our device
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotification) => {
console.log('Push received: ' + JSON.stringify(notification));
}
);
// Method called when tapping on a notification
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: PushNotificationActionPerformed) => {
console.log('Push action performed: ' + JSON.stringify(notification));
}
);
} catch (err) {
console.log(err);
}
}
const Home: React.FC = () => {
useIonViewDidEnter(() => {
registerNotification();
})
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Blank</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">Blank</IonTitle>
</IonToolbar>
</IonHeader>
<ExploreContainer />
</IonContent>
</IonPage>
);
};
export default Home; |
I use hook "capacitor:copy:after":
|
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
TL:DR : the step to reproduce the issue :
ionic start ua-test blank --type react --capacitor cd ua-test npx cap init ua-test com.ua.test.app --web-dir build --npm-client npm npm install @ionic-native/core npm install urbanairship-cordova npm install @ionic-native/urbanairship ionic cap sync ionic cap add android ionic cap open android
And the error :
What I've tried so far
place a
google-services.json
incapacitor-cordova-android-plugins
If I place a
google-services.json
here :I get a different error :
Which lead me here #1286 ending in
Rename the package name of
capacitor-cordova-android-plugins/src/main/AndroidManifest.xml
To match the id of my current firebase config. Which lead me here :
Which seems to be a bug with AndroidX.
Tried this : #2045 (comment) (with this repo on master) + Refactor > Migrate to AndroidX
And now... it works on Android.
The thing is, I shouldn't have to edit the package name of
capacitor-cordova-android-plugins/src/main/AndroidManifest.xml
since it's always generated.Do you have any idea how it could be easier to implement ?
Cheers
The text was updated successfully, but these errors were encountered: