特定のバージョンにおけるCordovaでの対応方法¶
Cordova 7.1未満を利用する場合の設定¶
名前空間および platform
タグを追加する¶
プロジェクト直下のconfig.xmlを開き、 widget
タグに xmlns:android="http://schemas.android.com/apk/res/android"
を追加してください。また、config.xmlの中に <platform name="android">
タグが存在しない場合、 widget
タグの下に追加してください。
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="..." version="1.0.0">
...
<platform name="android">
...
</platform>
custom-config-fileタグを追加する¶
Cordova 7.1未満をご利用する場合、config-fileタグが動作しないため、以下の手順で config.xml
を編集してください:
cordova-custom-configを導入
$ cordova plugin add cordova-custom-config
config-fileタグを追加する にて設定したXMLを一つの
custom-config-file
タグの中に記述し、さらにそのcustom-config-file
タグを<platform name="android">
タグの中に追加してください- "YOUR_PACKAGE_NAME" をアプリケーションのパッケージ名に置き換えてください
<custom-config-file parent="./application" target="AndroidManifest.xml"> <!-- Receiver --> <receiver android:name="io.repro.android.ReproReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="YOUR_PACKAGE_NAME" /> </intent-filter> </receiver> <!-- Notification Channel --> <meta-data android:name="io.repro.android.PushNotification.ChannelId" android:value="YOUR_CHANNEL_ID"> </meta-data> <meta-data android:name="io.repro.android.PushNotification.ChannelName" android:resource="@string/channel_name"> </meta-data> <meta-data android:name="io.repro.android.PushNotification.ChannelDescription" android:resource="@string/channel_description"> </meta-data> <meta-data android:name="io.repro.android.PushNotification.ShowBadge" android:value="true"> </meta-data> <!-- Icon and Accent Color --> <meta-data android:name="io.repro.android.PushNotification.SmallIcon" android:resource="@drawable/YOUR_ICON_ID"> </meta-data> <meta-data android:name="io.repro.android.PushNotification.AccentColor" android:resource="@color/YOUR_COLOR_ID"> </meta-data> </custom-config-file>
プロジェクト直下で下記の内容で
ReproStrings.xml
というファイルを作成してください:<?xml version='1.0' encoding='utf-8'?> <resources> <string name="channel_name">YOUR_CHANNEL_NAME</string> <string name="channel_description">YOUR_CHANNEL_DESCRIPTION</string> </resources>
config.xmlの
<platform name="android">
タグの中に下記の設定を追加してください:<resource-file src="ReproStrings.xml" target="res/values/ReproStrings.xml" />
Cordova Android 7.0未満を利用する場合の設定¶
google-services.json
ファイルを追加する¶
FCMの設定 (Android) でダウンロードした google-services.json
をプロジェクトのディレクトリにコピーし、
下記のXMLをconfig.xmlの <platform name="android">
タグの中に追加してください。
<resource-file src="google-services.json" target="google-services.json" />