Pl Oe
Pl Oe

Reputation: 99

Xamarin Push Notification Firebase Android 12 (exported)

i would like to implement the GettingStarted from the Package Github. So far so good if i do everything like in the Tutorial im getting the Error "Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]" for the crc640921eac73192168e.PNMessagingService. That means i have to add Code to the Manifest.xml with the property exported=true or false. But i cant figure out which Code i have to paste in the XML to make it work properly? In a furhter Question from another User Stackoverflow he got the answer for setting exported = false but he dont said which the exact code has to be, maybe so can help me :D

Upvotes: 6

Views: 3000

Answers (2)

Reinhard Sual
Reinhard Sual

Reputation: 91

For those who are still having this issue (which I am having hard time to search the answer), actually this issue is easily solved by adding Exported = false on Tag (It could be in Service, Activity etc.)

Example:

[Service (Exported=false)]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
   or
[Activity (Exported=false)]
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }]

For adding it into Android Manifest (just need either one, the above or below)

<service
android:name="crc64620eeeaa876b9f26.MessagingServiceHandler" 
android:exported="false">
    <intent-filter>
       <action android:name="com.google.firebase.MESSAGING_EVENT" />   
    </intent-filter>

Hope this help! Reinhard Sual

Upvotes: 8

Wendy Zang - MSFT
Wendy Zang - MSFT

Reputation: 10978

Put the this into receiver of the AndroidManifest.xml file. This is the Receiver of this plugin. You need to put this inside the <application> tag.

<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
    <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>

For more details, you could check the AndroidManifest.xml of the sample for this plugin.

Upvotes: 0

Related Questions