How to implement Push Notifications in PCL Project?

How to implement Push Notifications in PCL Project?

Is there any plugin or samples for it?

Thanks in advance!

Best Answers

  • RamprasadKRamprasadK USMember ✭✭
    Accepted Answer
  • RamprasadKRamprasadK USMember ✭✭
    Accepted Answer
  • RamprasadKRamprasadK USMember ✭✭
    edited November 1 Accepted Answer

    Hi @JassimRahma

    No. Don't write this code in app.xaml.In app.xaml , you can write only like application styles.

    You have to add this code in Android Project -> Manifest File ->Application tags.
    This is platform specific code.
    <application> <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> </application>

    This will work for sure.

Answers

  • Praveen.BPraveen.B INMember ✭✭

    Here is the link for you which demonstrates the implementation of push notifications in Xamarin.Forms

    https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push

  • RamprasadKRamprasadK USMember ✭✭
    Accepted Answer
  • RamprasadKRamprasadK USMember ✭✭
    Accepted Answer
  • JassimRahmaJassimRahma USMember ✭✭✭
    edited November 1

    As per documentation, it's asking to add below code to the application tag:

        <receiver android:name="com.onesignal.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="${manifestApplicationId}" />
            </intent-filter>
        </receiver>
    

    so where shall I keep this if I am using cross platform PCL?

    I tried to add it to the app.xaml in the common project but got this error:

    **Error: 'android' is an undeclared prefix. Line 6, position 15. (Adel_Al_Asoomi)
    **

  • RamprasadKRamprasadK USMember ✭✭
    edited November 1 Accepted Answer

    Hi @JassimRahma

    No. Don't write this code in app.xaml.In app.xaml , you can write only like application styles.

    You have to add this code in Android Project -> Manifest File ->Application tags.
    This is platform specific code.
    <application> <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> </application>

    This will work for sure.

Sign In or Register to comment.