'Resource.String' Does not contain a definition for 'gcm_defaultSenderId' Xamarin

Asked

Viewed 318 times

0

I’m implementing Push Notification in my app, it was working, more now the error in two variables not defined in Resource in google_app_id and gcm_defaultSenderId. When I try to add them manually in Resource from the right of first more on second see that I will run already accuses me the error again (Resource file and overwritten)

what may be taking place so they don’t get fixed in my application ?

inserir a descrição da imagem aqui

   if (!GetString(Resource.String.google_app_id).Equals("000000000000000000000000000"))
                throw new System.Exception("Invalid Json file");

        Task.Run(() => {
            var instanceId = FirebaseInstanceId.Instance;
            instanceId.DeleteInstanceId();
            Android.Util.Log.Debug("TAG", "{0} {1}", instanceId.Token, instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
        });

1 answer

0


This error occurs when you try to use a string that was not created in the Strings.xml file.

Inside the root of your project, log into the Resources/values folder and open the Strings.xml file. If you do not have this file, create a new one exactly with this name "Strings" of XML type.

Its structure is the following (already with the strings you need):

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="gcm_defaultSenderId">12345</string>
  <string name="google_app_id">12345</string>
</resources>

If you have more than one Strings.xml file, which can happen in case you are using multi-language support, add the two strings in all Strings.xml files to avoid possible errors.

Don’t forget to give Rebuild in the project after modifying these files.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.