简体   繁体   中英

mobilefirst push notification change android app_name

Hello im working in a mobilefirst 6.3 hybrid app, and i have a problem when changing the app_name from my string.xml.

i have my hybrid name app <string name="app_name">ASDFGHJK</string> and i nee to change that to <string name="app_name">ASDF GHJK</string> , when ive change de app_name:

when the app is in the background, the click on the push doesnt do anything, and when im in the app, the receiver method doesnt trigger, how can a chage my app name witout having this problem?

The app_name value in res\\values\\strings.xml is used internally to create Intent objects. So when the app is closed and the GCMIntentService receives a message, it creates an intent with the action as <packagename>.<app_name> and send it to notification service to show the notification in the notifications bar.

This is the intent name as used in AndroidManifest.xml to indicate that app has to be launched on tapping the notification:

<activity android:name=".PushNotifications" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:screenOrientation="sensor"> 
    ....
    <intent-filter> 
        <action android:name="com.PushNotifications.PushNotifications.NOTIFICATION"/>  
        <category android:name="android.intent.category.DEFAULT"/> 
    </intent-filter> 

So now if the app_name is changed to any other string, internally the Intent will be created as com.PushNotifications.<new_name> .
But the AndroidManifest.xml still has for example com.PushNotifications.PushNotifications (in the case of the sample application), so the app is not getting launched as the intent action is different.

To display the application with a different name, follow these steps:

  1. In strings.xml, add an additional new_name_value
  2. In AndroidManifest.xml , modify the label with the new string name

     <application android:label="@string/app_new_name" android:icon="@drawable/icon"> <activity android:name=".PushNotifications" android:label="@string/app_new_name"... 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM