Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question [Unity Push Notification] Exception message "Failed to initialize Push Notification plugin ..."

Discussion in 'Player Engagement' started by rdossantos_unity, Apr 6, 2023.

  1. rdossantos_unity

    rdossantos_unity

    Joined:
    Mar 7, 2022
    Posts:
    7
    Hello ;) ,

    I think I made all setup inside the this document correctly (Like Firebase, Unity Editor, Unity Dashboard). No error during the build process. But when I open my Android device, I got this error message when run the
    RegisterForPushNotificationsAsync method:

    Failed to initialize Push Notification plugin instance and register the device for remote notifications

    - The build was made on Unity Cloud Build (2022.2.13f1)
    - I'm using the same script sample to test
    - I'm testing an apk (not a published build)

    upload_2023-4-6_1-27-33.png

    [EDIT]
    - I made a local build (2022.2.12f1) and got the same error

    [OBS]
    - I geeting this message before the exception message:

    FirebaseApp: Device unlocked: initializing all Firebase APIs for app UNITY_PUSH_NOTIFICATIONS
     
    Last edited: Apr 11, 2023
  2. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    266
    Hi rdossantos,
    thanks for posting on the forums.
    Is this a sample project? If so would it be possible to send me the project in a DM?

    I would love to explore the code and see what may be going wrong. What version of the Push Notifications Beta are you currently using?
     
  3. rdossantos_unity

    rdossantos_unity

    Joined:
    Mar 7, 2022
    Posts:
    7
    Thanks, @SebT_Unity .

    - It's not a sample project. I'm implementing direct to a company project because we already have some configs like Firebase
    - I'm using the Push Notification 3.0.1-pre.1

    My configs:

    upload_2023-4-11_18-3-23.png

    upload_2023-4-11_18-4-38.png

    [OBS] If this can help:

    - We are using Facebook sdk, Iron Source and Firebase Analytics and Crashlytics.
    upload_2023-4-11_18-28-7.png

    upload_2023-4-11_18-30-16.png

    upload_2023-4-11_18-35-28.png
     
    SebT_Unity likes this.
  4. rdossantos_unity

    rdossantos_unity

    Joined:
    Mar 7, 2022
    Posts:
    7
    [ANDROID UPDATE]

    - Trying to fix other SDK integration I team member tell me that our Android Resolver is not automatically running, so a need to run it manually.
    - After that the RegisterForPushNotificationsAsync worked ;) The push token was generated and I can send a Test Push Notification
    - My suggestion is to add on the guide this part


    upload_2023-4-19_22-39-41.png


    [IOS UPDATE]

    - I'm getting some iOS errors during the XCode build process on Unity Cloud Build. But I'm testing more to see if I can find the solution.


    @SebT_Unity
     
  5. rdossantos_unity

    rdossantos_unity

    Joined:
    Mar 7, 2022
    Posts:
    7
    [IOS UPDATE]

    I'm getting the error below while I'm building on Unity Cloud Build.

    upload_2023-4-19_23-25-31.png
    Error Detail:
    - INFO: ▸ ❌ error: Provisioning profile "----" has app ID "----", which does not match the bundle ID "----.notificationservice". (in target 'notificationservice' from project 'Unity-iPhone')


    I search on the project about the notificationservice key and saw that Push Notification Process appends this information to my identifier.

    upload_2023-4-19_23-31-20.png

    Question:
    - What do I have to make to work?

    Extra Info:

    - Unity Version: Unity 2022.2.11f1
    - Xcode Version: Xcode 13.4.1
    - Ruby version: 2.7.4
     
  6. rdossantos_unity

    rdossantos_unity

    Joined:
    Mar 7, 2022
    Posts:
    7
    I will move the last question to a new topic. To be more specific:

    Topic Link
     
  7. Dan-Lyrebird

    Dan-Lyrebird

    Joined:
    Mar 1, 2022
    Posts:
    2
    Hey,
    i cant register my app, too. Only get the exception while running my mobile app "Failed to register the device for remote notification". (only trying it for Android)

    I think i followed all steps written in the documentary
    - imported the push-notification sdk 3.01 Preview
    - Create a Firebase account for my game and import the google-services.json
    - generate an service account key
    - add generated key to Liveops->Push Notifications -> Settings
    - add all information about firebase to Unity->projectsetting ->Push notifications
    - enable Cloud Messaging API (Legacy) in firebase

    I am using Unity 2021.3.8 and my mobile phone using version 12.
    I Copied the code above and resolve with the android resolver, but the exception is still triggered.

    Does anyone have an idea how i to solve this?
     
  8. rdossantos_unity

    rdossantos_unity

    Joined:
    Mar 7, 2022
    Posts:
    7
    Hey, @Dan-Lyrebird

    - Are you added the Push Notification API Keys for android?

    upload_2023-5-4_19-39-44.png
     
  9. Dan-Lyrebird

    Dan-Lyrebird

    Joined:
    Mar 1, 2022
    Posts:
    2
    Hey @rdossantos_unity,
    Yes i added the key and using my development environment in my current build. (Like in Remote Config, Analytics, Leaderboard etc.)

    Push_Notification_Settings.png
     
  10. navs_unopnd

    navs_unopnd

    Joined:
    May 13, 2022
    Posts:
    1
    @rdossantos_unity

    I had the same symptoms as you. In my case, There was an additional space character at the end of the "Firebase App Key" because I had copied the id by just doubleclicking in the web browser.
    After removing the space , I could get the push registration token.
    Hope this helps..