- Generate APNs key (p8) from Apple Developer
- Upload the APN authentication key to Google Firebase
- Upload GoogleService-Info.plist to your project folder
- Check background modes > Remote notifications in Xcode
- Add push notifications of capabilities in Xcode
iOS 15.5 / Xcode 13.4.1
I have done all of the above, but adroid receives push notifications, but iOS does not work. Also, when the app is run in Xcode, the notification setting item is not visible in the iPhone settings. What's the problem? Please ask for a professional solution. And thank you in advance.
<content src="https://abc.xxxxx.com/" />
And in config.xml, the first page is set to load an external url.
2022-08-01 22:33:06.795502+0900 HAROO.D[810:173282] Apache Cordova native platform version 6.2.0 is starting.
2022-08-01 22:33:06.795585+0900 HAROO.D[810:173282] Multi-tasking -> Device: YES, App: YES
2022-08-01 22:33:06.801480+0900 HAROO.D[810:173282] CDVWKWebViewEngine: trying to inject XHR polyfill
2022-08-01 22:33:06.802036+0900 HAROO.D[810:173282] The preference key "KeyboardResize" is not defined and will default to "TRUE"
2022-08-01 22:33:06.802064+0900 HAROO.D[810:173282] The preference key "AutoInjectCordova" is not defined and will default to "FALSE"
2022-08-01 22:33:06.802080+0900 HAROO.D[810:173282] The preference key "AudioCanMix" is not defined and will default to "FALSE"
2022-08-01 22:33:06.812203+0900 HAROO.D[810:173282] The preference key "WKSuspendInBackground" is not defined and will default to "TRUE"
2022-08-01 22:33:06.812236+0900 HAROO.D[810:173282] The preference key "MediaPlaybackAllowsAirPlay" is not defined and will default to "TRUE"
2022-08-01 22:33:06.886762+0900 HAROO.D[810:173282] The preference key "KeyboardAppearanceDark" is not defined and will default to "FALSE"
2022-08-01 22:33:06.886820+0900 HAROO.D[810:173282] The preference key "AllowLinkPreview" is not defined and will default to "FALSE"
2022-08-01 22:33:06.886846+0900 HAROO.D[810:173282] The preference key "AllowBackForwardNavigationGestures" is not defined and will default to "FALSE"
2022-08-01 22:33:06.886861+0900 HAROO.D[810:173282] CDVWKWebViewEngine will reload WKWebView if required on resume
2022-08-01 22:33:06.886875+0900 HAROO.D[810:173282] Using Ionic WKWebView
2022-08-01 22:33:06.886973+0900 HAROO.D[810:173282] [CDVTimer][console] 0.015020ms
2022-08-01 22:33:06.887019+0900 HAROO.D[810:173282] [CDVTimer][handleopenurl] 0.018954ms
2022-08-01 22:33:06.887889+0900 HAROO.D[810:173282] [CDVTimer][intentandnavigationfilter] 0.851035ms
2022-08-01 22:33:06.887935+0900 HAROO.D[810:173282] [CDVTimer][gesturehandler] 0.024915ms
2022-08-01 22:33:06.888535+0900 HAROO.D[810:173282] [CDVTimer][file] 0.568986ms
2022-08-01 22:33:06.888586+0900 HAROO.D[810:173282] The preference key "KeyboardResize" is not defined and will default to "TRUE"
2022-08-01 22:33:06.888652+0900 HAROO.D[810:173282] CDVIonicKeyboard: resize mode 1
2022-08-01 22:33:06.888671+0900 HAROO.D[810:173282] The preference key "KeyboardAppearanceDark" is not defined and will default to "FALSE"
2022-08-01 22:33:06.888697+0900 HAROO.D[810:173282] [CDVTimer][cdvionickeyboard] 0.138998ms
2022-08-01 22:33:06.889398+0900 HAROO.D[810:173282] [CDVTimer][splashscreen] 0.682950ms
2022-08-01 22:33:06.890021+0900 HAROO.D[810:173282] [CDVTimer][statusbar] 0.596046ms
2022-08-01 22:33:06.890047+0900 HAROO.D[810:173282] [CDVTimer][TotalPluginStartup] 3.098011ms
2022-08-01 22:33:06.992791+0900 HAROO.D[810:173282] DidFinishLaunchingWithOptions
2022-08-01 22:33:07.025189+0900 HAROO.D[810:173282] app become active
2022-08-01 22:33:07.294510+0900 HAROO.D[810:173282] GoogleService-Info.plist found, setup: [FIRApp configureWithOptions]
2022-08-01 22:33:07.309151+0900 HAROO.D[810:173550] 7.4.0 - [Firebase/Core][I-COR000001] Configuring the default app.
2022-08-01 22:33:07.312633+0900 HAROO.D[810:173548] 7.4.0 - [Firebase/Installations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
2022-08-01 22:33:07.312731+0900 HAROO.D[810:173548] 7.4.0 - [Firebase/Core][I-COR000033] Data Collection flag is not set.
2022-08-01 22:33:07.315187+0900 HAROO.D[810:173548] 7.4.0 - [Firebase/Messaging][I-FCM002000] FIRMessaging library version 7.4.0
2022-08-01 22:33:07.315471+0900 HAROO.D[810:173548] 7.4.0 - [GULReachability][I-REA902003] Monitoring the network status
2022-08-01 22:33:07.315747+0900 HAROO.D[810:173548] 7.4.0 - [Firebase/Installations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
2022-08-01 22:33:07.316483+0900 HAROO.D[810:173282] Device FCM Token: dKTn2hbYS08JvY62xEB7Vc:APA91bGBGx1heU5WV0k4uPYEn4_O4kmaLdjw............................1raAU6lYRbwd99vvLQT6a-vlfqlO..........CEuccrqEGu9u_Dc2lJ3OcxROMfjQHCXEHshTX7oGVq
2022-08-01 22:33:07.316787+0900 HAROO.D[810:173548] 7.4.0 - [Firebase/Installations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
2022-08-01 22:33:07.317372+0900 HAROO.D[810:173553] 7.4.0 - [Firebase/Installations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
2022-08-01 22:33:07.319550+0900 HAROO.D[810:173554] 7.4.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=dKTn2hbYS08JvY62xEB7Vc:APA91bGBGx1heU5WV0k4uPYEn4_O4kmaLdjwFbFXOyMXTJ6tHPB1raAU6lYRbwd99vvLQT6a-vlfqlO_vVYMdOMScVtY5-YoC_CEuccrqEGu9u_Dc2lJ3OcxROMfjQHCXEHshTX7oGVq&app=com.the14days.haroo&device=5529516816803637881&app_ver=1.0.3&X-gcm.topic=/topics/ios&X-scope=/topics/ios
2022-08-01 22:33:07.321541+0900 HAROO.D[810:173552] 7.4.0 - [Firebase/Messaging][I-FCM017000] Topic subscription request: sender=dKTn2hbYS08JvY62xEB7Vc:APA91bGBGx1heU5WV0k4uPYEn4_O4kmaLdjwFbFXOyMXTJ6tHPB1raAU6lYRbwd99vvLQT6a-vlfqlO_vVYMdOMScVtY5-YoC_CEuccrqEGu9u_Dc2lJ3OcxROMfjQHCXEHshTX7oGVq&app=com.the14days.haroo&device=5529516816803637881&app_ver=1.0.3&X-gcm.topic=/topics/all&X-scope=/topics/all
2022-08-01 22:33:07.400786+0900 HAROO.D[810:173554] 7.4.0 - [GULReachability][I-REA902004] Network status has changed. Code:2, status:Connected
2022-08-01 22:33:07.685685+0900 HAROO.D[810:173282] The preference key "AutoHideSplashScreen" is not defined and will default to "TRUE"
2022-08-01 22:33:08.573591+0900 HAROO.D[810:173553] 7.4.0 - [Firebase/Messaging][I-FCM004003] Successfully subscribed to topic /topics/ios
2022-08-01 22:33:08.574936+0900 HAROO.D[810:173554] 7.4.0 - [Firebase/Messaging][I-FCM004003] Successfully subscribed to topic /topics/all
package.jason
Ionic CLI : 6.20.1
{
"name": "XXXX.D",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^14.0.0",
"@angular/core": "^14.0.0",
"@angular/forms": "^14.0.0",
"@angular/platform-browser": "^14.0.0",
"@angular/platform-browser-dynamic": "^14.0.0",
"@angular/router": "^14.0.0",
"@awesome-cordova-plugins/camera": "^5.44.0",
"@awesome-cordova-plugins/fcm": "^5.44.0",
"@awesome-cordova-plugins/geolocation": "^5.44.0",
"@awesome-cordova-plugins/health": "^5.44.0",
"@awesome-cordova-plugins/splash-screen": "^5.44.0",
"@awesome-cordova-plugins/status-bar": "^5.44.0",
"@capacitor/app": "1.1.1",
"@capacitor/core": "3.6.0",
"@capacitor/haptics": "1.1.4",
"@capacitor/keyboard": "1.2.3",
"@capacitor/status-bar": "1.0.8",
"@ionic-native/fcm": "^5.36.0",
"@ionic/angular": "^6.1.9",
"@ionic/cordova-builders": "^6.1.0",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^14.0.0",
"@angular-eslint/builder": "~13.0.1",
"@angular-eslint/eslint-plugin": "~13.0.1",
"@angular-eslint/eslint-plugin-template": "~13.0.1",
"@angular-eslint/template-parser": "~13.0.1",
"@angular/cli": "^14.0.0",
"@angular/compiler": "^14.0.0",
"@angular/compiler-cli": "^14.0.0",
"@angular/language-service": "^14.0.0",
"@capacitor/cli": "3.6.0",
"@ionic/angular-toolkit": "^6.1.0",
"@ionic/lab": "3.2.13",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "5.3.0",
"@typescript-eslint/parser": "5.3.0",
"cordova-android": "^10.1.2",
"cordova-ios": "^6.2.0",
"cordova-plugin-camera": "^6.0.0",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-fcm-with-dependecy-updated": "^7.8.0",
"cordova-plugin-file": "^7.0.0",
"cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer",
"cordova-plugin-geolocation": "^4.1.0",
"cordova-plugin-health": "^2.0.3",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^5.0.0",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-wkwebview-engine": "^1.2.2",
"eslint": "^7.6.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"typescript": "~4.7.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-health": {
"HEALTH_READ_PERMISSION": "App needs read access",
"HEALTH_WRITE_PERMISSION": "App needs write access",
"PLAY_AUTH_VERSION": "19.0.0",
"FIT_API_VERSION": "20.0.0"
},
"cordova-plugin-fcm-with-dependecy-updated": {
"ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher",
"ANDROID_FCM_VERSION": "21.0.0",
"ANDROID_FIREBASE_BOM_VERSION": "26.0.0",
"ANDROID_GOOGLE_SERVICES_VERSION": "4.3.4",
"ANDROID_GRADLE_TOOLS_VERSION": "4.1.0",
"IOS_FIREBASE_MESSAGING_VERSION": "~> 7.4.0"
},
"cordova-plugin-camera": {
"ANDROIDX_CORE_VERSION": "1.6.+"
},
"cordova-plugin-geolocation": {
"GPS_REQUIRED": "true"
},
"cordova-plugin-wkwebview-engine": {},
"cordova-plugin-whitelist": {}
},
"platforms": [
"android",
"ios"
]
}
}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { SplashScreen } from '@awesome-cordova-plugins/splash-screen/ngx';
import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
import { FCM } from '@awesome-cordova-plugins/fcm/ngx';
import { Health } from '@awesome-cordova-plugins/health/ngx';
import { Camera, CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
import { Geolocation } from '@awesome-cordova-plugins/geolocation/ngx';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
FCM,
Health,
Camera,
Geolocation,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent],
})
export class AppModule {}
app.component.ts
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@awesome-cordova-plugins/splash-screen/ngx';
import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
import { FCM } from '@awesome-cordova-plugins/fcm/ngx';
import { Health } from '@awesome-cordova-plugins/health/ngx';
import { Camera, CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
import { Geolocation } from '@awesome-cordova-plugins/geolocation/ngx';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private fcm: FCM,
private health: Health,
private camera: Camera,
private geolocation: Geolocation
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.statusBar.overlaysWebView(true);
this.statusBar.backgroundColorByHexString('#ffffff');
this.splashScreen.hide();
const w: any = window;
w.FCMPlugin.requestPushPermissionIOS(() => {
console.log('push permissions recieved');
}, (e) => {
console.log('push permissions failed', e);
});
this.fcm.subscribeToTopic('marketing');
this.fcm.getToken().then(token => {
// backend.registerToken(token);
console.log(token);
});
this.fcm.onNotification().subscribe(data => {
if(data.wasTapped){
console.log("Received in background");
} else {
console.log("Received in foreground");
};
});
this.fcm.onTokenRefresh().subscribe(token => {
// backend.registerToken(token);
console.log(token);
});
this.fcm.hasPermission().then(hasPermission => {
if (hasPermission) {
console.log("Has permission!");
}
})
this.fcm.clearAllNotifications();
this.fcm.unsubscribeFromTopic('marketing');
});
}
}