SMS using twilio from mobile app not working - gradle

As per the guidelines in this tutorial.
I've completed everything. But it's not working. No errors are occurring. I don't know where to check for the issues. Please can someone help me with a solution or at least where to look for issues?
Please find below manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="uhnm.stroke.strokeapp_secondscreen">
<dist:module dist:instant="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".NIHSSActivityPage4" android:windowSoftInputMode="adjustPan"/>
<activity android:name=".TeamsDisplay" android:windowSoftInputMode="adjustPan" />
<activity android:name=".imageActivity" android:windowSoftInputMode="adjustPan" />
<activity android:name=".timesActivity" />
<activity android:name=".configurationActivity" />
<activity android:name=".addConsultants" />
<activity android:name=".NIHSSActivityFinalPage"android:windowSoftInputMode="adjustPan" />
<activity android:name=".NIHSSActivityPage3" android:windowSoftInputMode="adjustPan" />
<activity android:name=".NIHSSActivityPage2" android:windowSoftInputMode="adjustPan" />
<activity android:name=".MainActivity" android:windowSoftInputMode="adjustPan" />
<activity android:name=".EnterBrainTracker" />
<activity android:name=".NIHSSActivity" android:windowSoftInputMode="adjustPan" />
<activity
android:name=".signIn"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="strokeapp.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
</application>
</manifest>
Here the app gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
//useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "uhnm.stroke.strokeapp_secondscreen"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions
{
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation group: "com.twilio.sdk", name: "twilio", version: "7.44.0"
implementation 'com.squareup.okhttp3:okhttp:4.2.1'
}

Related

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED on Android 6 (API 23)

I am unable to deploy my app (in debug/release) on Android 6 (API 23) but on Android 8 (API 26) and Android 9 (API 28) everything works fine. There is a INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error in output.
Output:
Detecting installed packages...
Copying application to device...
90% ... 21184kb of 23527kb copied
100% ... 23527kb of 23527kb copied
ADB0000: Deployment failed Mono.AndroidTools.InstallFailedException:
Unexpected install output: pkg:
/data/local/tmp/com.companyname.appname-Signed.apk Failure
[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1 t) in E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
at System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
ADB0010: Unexpected install output: pkg:
/data/local/tmp/com.companyname.appname-Signed.apk Failure
[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
at
Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String
output, String packageName) in
E:\A_work\275\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line
345 at
Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1
t) in
E:\A\_work\275\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line
753 at
System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute() Done building project
"AppNameInCamelCase.Droid.csproj" -- FAILED.
Blockquote
Build FAILED.
2>Deployment failed to Samsung SM-G800F.
========== Build: 1 succeeded, 0 failed, 6 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
Here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.companynameallinsmall.appnameallinsmall" android:versionName="X.X.x" android:versionCode="XXXYYY">
<!--Target SDK version should be 25+ in order to ask for permissions in popups.-->
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<!--Permissions which are requested via popup.-->
<!--For logging and data writing.-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--For picking photo.-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!--For location-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!--Permissions granted during installation.-->
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature android:name="android.hardware.sensor.compass" android:required="false" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<uses-feature android:name="android.hardware.location" android:required="true" />
<uses-feature android:name="android.hardware.location.gps" android:required="true" />
<uses-feature android:name="android.hardware.location.network" android:required="true" />
<application android:label="CamelCase Name" android:theme="#style/STAPPCustomTheme">
<uses-library android:name="org.apache.http.legacy" android:required="false" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="YXSIBIDGA......" />
</application>
</manifest>
Compiled AndroidManifest - Obj Folder
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.companynameallinsmall.appnameallinsmall" android:versionName="X.X.x" android:versionCode="XXXYYY">
<!--Target SDK version should be 25+ in order to ask for permissions in popups.-->
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<!--Permissions which are requested via popup.-->
<!--For logging and sensor data writing.-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--For picking photo.-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!--For location-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!--Permissions granted during installation.-->
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-feature android:name="android.hardware.sensor.compass" android:required="false" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<uses-feature android:name="android.hardware.location" android:required="true" />
<uses-feature android:name="android.hardware.location.gps" android:required="true" />
<uses-feature android:name="android.hardware.location.network" android:required="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<application android:label="CamelCase Name" android:theme="#style/STAPPCustomTheme" android:name="android.app.Application" android:allowBackup="true" android:icon="#mipmap/icon" android:debuggable="true">
<uses-library android:name="org.apache.http.legacy" android:required="false" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="YXSIBIDGA......" />
<activity android:configChanges="orientation|screenSize" android:icon="#mipmap/icon" android:label="CamelCase Name" android:launchMode="singleTop" android:screenOrientation="portrait" android:name="md***********.MainActivity" />
<activity android:configChanges="orientation|screenSize" android:icon="#mipmap/icon" android:label="CamelCase Name" android:noHistory="true" android:screenOrientation="portrait" android:theme="#style/Theme.SplashNotPowered" android:name="md***********.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="com.companynameallinsmall.appnameallinsmall.fileProvider" android:exported="false" android:grantUriPermissions="true" android:name="Companyname.Utils.fileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/companynameallinsmall_utils_fileprovider_file_paths" />
</provider>
<service android:name="md***********.MatchaBackgroundService" />
<receiver android:enabled="true" android:exported="false" android:label="Connectivity Plugin Broadcast Receiver" android:name="md***********.ConnectivityChangeBroadcastReceiver" />
<activity android:configChanges="orientation|screenSize" android:name="md***********.MediaPickerActivity" />
<receiver android:enabled="true" android:exported="false" android:label="Essentials Battery Broadcast Receiver" android:name="md***********.BatteryBroadcastReceiver" />
<provider android:authorities="com.companynameallinsmall.appnameallinsmall.fileProvider" android:exported="false" android:grantUriPermissions="true" android:name="xamarin.essentials.fileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/xamarin_essentials_fileprovider_file_paths" />
</provider>
<receiver android:enabled="true" android:exported="false" android:name="md***********.PowerSaveModeBroadcastReceiver" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="com.companynameallinsmall.appnameallinsmall.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.com.companynameallinsmall.appnameallinsmall" />
</intent-filter>
</receiver>
<activity android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
</application>
</manifest>
Lint output AndroidManifest.xml:
Scanning manifest:
manifest: Error: Can't find API database; API check not performed [LintError]
AndroidManifest.xml:43: Warning: Use '$' instead of '.' for inner
classes (or use only lowercase letters in package names); replace
"Companyname.Utils.fileProvider" with "Companyname$Utils$fileProvider"
[InnerclassSeparator]
<provider android:authorities="com.companynameallinsmall.fileProvider"
android:exported="false" android:grantUriPermissions="true" android:name="Companyname.Utils.fileProvider">
AndroidManifest.xml:33: Error: Avoid hardcoding the debug mode; leaving it out allows debug
and release builds to automatically assign one [HardcodedDebugMode]
<application android:label="CamelCase Name" android:theme="#style/STAPPCustomTheme" android:name="android.app.Application" android:allowBackup="true" android:icon="#mipmap/icon" android:debuggable="true">
AndroidManifest.xml:33: Warning: On SDK
version 23 and up, your app data will be automatically backed up and
restored on app install. Consider adding the attribute
android:fullBackupContent to specify an #xml resource which configures
which files to backup. More info:
https://developer.android.com/training/backup/autosyncapi.html
[AllowBackup]
<application android:label="CamelCase Name" android:theme="#style/STAPPCustomTheme"
android:name="android.app.Application" android:allowBackup="true"
android:icon="#mipmap/icon" android:debuggable="true">
AndroidManifest.xml:33: Warning: App is not indexable by Google
Search; consider adding at least one Activity with an ACTION-VIEW
intent filter. See issue explanation for more details.
[GoogleAppIndexingWarning]
<application android:label="CamelCase Name" android:theme="#style/STAPPCustomTheme" android:name="android.app.Application" android:allowBackup="true" android:icon="#mipmap/icon" android:debuggable="true">
^ 2 errors, 3
warnings
My Installed Android SDKs
1.To resolve the first error:
manifest: Error: Can't find API database; API check not performed
[LintError]
You can try to set the Linking option to None
2.To resolve the second error:
AndroidManifest.xml:33: Error: Avoid hardcoding the debug mode;
leaving it out allows debug and release builds to automatically assign
one [HardcodedDebugMode]
You can try to disable Debugging in your code:
For more details, you can check:
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=windows#disable-debugging
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debuggable-attribute
Note:
If your app still has problems,could you please post a basic demo so that we can test on my side?

getting error after adding elegant button dependency

after adding this
implementation'com.cepheuen.elegant-number-button:lib:1.0.2'
getting the error every time i add this dependency
Manifest merger failed : Attribute application#theme value=(#style/Theme.AppCompat.Light.NoActionBar) from AndroidManifest.xml:13:9-65
is also present at [com.cepheuen.elegant-number-button:lib:1.0.2] AndroidManifest.xml:16:9-40 value=(#style/AppTheme).
Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:7:5-27:19 to override.
which other dependency can be used for elegant button
build.gradle module app file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.sharma.digimenu"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'
implementation 'com.firebaseui:firebase-ui-storage:4.0.0'
implementation 'com.firebaseui:firebase-ui-database:4.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation'com.cepheuen.elegant-number-button:lib:1.0.2'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
apply plugin: 'com.google.gms.google-services'
Do the following changes in Manifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:theme"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Home"
android:label="#string/title_activity_home"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" />
<activity android:name=".FoodList"></activity>
</application>
Follow the instruction, add tools:replace="android:theme" to your <application> element.

Implementing SearchView in Toolbar

I am trying to implement the SearchView in my ToolBar, but when I type something and confirm the search, it does not open up the activity for result.
The search appears in MainActivity and when the user types something and presses the search button, it should open SearchResultAcivity. But it does not open.
Here is what I have done:
AndroidManifest:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SearchResultsActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>
searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="#string/app_name"
android:hint="search" >
</searchable>
Menu Item:
<item
android:id="#+id/action_search"
android:title="Search"
android:orderInCategory="100"
android:icon="#drawable/search"
app:actionViewClass = "android.support.v7.widget.SearchView"
app:showAsAction="collapseActionView|ifRoom" />
And:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true); // Iconify the widget
return true;
}
In your manifest you make a mistake.
I assume that you want search in all activitys and for working you need to put this before mainactivity:
<meta-data
android:name="android.app.default_searchable"
android:value="yourpakagename.yourresultactivity" />
And put this inside searchresultactivity:
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
the result is like that:
<meta-data
android:name="android.app.default_searchable"
android:value="yorpakagename.yourresultactivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".searchableactivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>

My app supports no device

I've got a big problem with my first app. I've uploaded the app earlier this day to the Google Play Store and there it says that my app supports zero devices. What am I doing wrong? Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:resizeable="true" />
<uses-feature
android:name="android.service.wallpaper"
android:required="true">
</uses-feature>
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="app.wallpaper.com.giflivewallpaper.MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="app.wallpaper.com.giflivewallpaper.GIFWallpaperService"
android:enabled="true"
android:label="Particle Live Wallpaper"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/wallpaper" >
</meta-data>
</service>
</application>
In your uses-feature, did you mean android.software.live_wallpaper?
<uses-feature
android:name="android.software.live_wallpaper"
android:required="true">
</uses-feature>
http://developer.android.com/guide/topics/manifest/uses-feature-element.html

Parse Unity Push Sample not working

I am struggling of using Parse on my Unity android application. Have been working on several days but no success yet. No matter how hard I try, I couldn't get my device token registered for Android which is needed for sending push notifications to android. Below is my sample code and manifest snippet..
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.JoyDash.Movies.permission.C2D_MESSAGE" />
<uses-permission android:name="com.JoyDash.Movies.permission.C2D_MESSAGE" />
<!--Parse Push notification receiver-->
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.JoyDash.Movies.Receiver" android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
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="com.JoyDash.Movies" />
</intent-filter>
</receiver>
<!--<receiver android:name="com.parse.ParsePushBroadcastReceiver" 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="com.JoyDash.Movies" />
</intent-filter>
</receiver>
<service android:name="com.parse.ParsePushService" />-->
#if UNITY_IOS
NotificationServices.RegisterForRemoteNotificationTypes (RemoteNotificationType.Alert |
RemoteNotificationType.Badge |
RemoteNotificationType.Sound);
#endif
//ParsePush.SubscribeAsync
Debug.Log("Registration with Parse Push. : " + Application.platform);
ParsePush.ParsePushNotificationReceived += (sender, args) =>
{
if (Application.platform == RuntimePlatform.Android)
{
AndroidJavaClass parseUnityHelper = new AndroidJavaClass("com.parse.ParseUnityHelper");
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
// Call default behavior.
Debug.Log("Calling Parse from Unity and Payload is : " + args.Payload);
parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.Payload.ToString());
//parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.Payload.StringPayload);
}
else if (Application.platform == RuntimePlatform.IPhonePlayer)
{
//IDictionary<string, object> payload = args.Payload;
//foreach (string key in payload)
//{
// Debug.Log("Payload: " + key + ": " + payload[key].ToString());
//}
}
};
//Parse Installation
Debug.Log("Device Token : " + ParseInstallation.CurrentInstallation.DeviceToken);
if (ParseInstallation.CurrentInstallation != null && !string.IsNullOrEmpty(ParseInstallation.CurrentInstallation.DeviceToken))
{
Debug.Log("Device Token : " + ParseInstallation.CurrentInstallation.DeviceToken);
}
else
{
//Create a new parse installation
//ParseInstallation.CurrentInstallation.SaveAsync().ContinueWith(t =>
// {
// if (t.IsFaulted || t.IsCanceled)
// {
// Debug.Log("Parse installation failed to save.");
// }
// else
// {
// Debug.Log("Parse installation saved successfully.");
// }
// });
//ParseInstallation.cre
Debug.Log("There is no installation data received for this device.. Now subscribing to a channel");
ParsePush.SubscribeAsync("Channel01").ContinueWith(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
Debug.Log("Subscription of push notification failed.");
}
else
{
Debug.Log("Push notification subscribed successfully.");
}
});
//installation.
}
"Parse Unity Push Sample not working", agree!! boy, such a pain in the ( Y )
I've been fighting with Unity Parse Pushes for days(a week?) and I just solve it. I am so, so, happy, I want to share my happiness (first time in my life I write at StackOverflow, guess it was about time...)
Not sure if this will solve your problem, but for sure you have something wrong at this line:
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
We have to change "currentActivity" for what ever is your current activity. In my case I have written this:
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject> ("com.unity3d.player.UnityPlayerNativeActivity");
Because that's the name of my activity in my AndroidManifest.xml
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:launchMode="singleTask" android:screenOrientation="landscape">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Still, it might not solve your problem. So, just in case, I copy paste my code!
AndroidManifest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.XXXX.YYYY" android:versionName="1" android:versionCode="7">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.XXXX.YYYY.permission.C2D_MESSAGE" />
<uses-permission android:name="com.XXXX.YYYY.permission.C2D_MESSAGE" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="false">
<service android:name="com.parse.ParsePushService" />
<receiver android:name="com.parse.ParsePushBroadcastReceiver" 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" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
<category android:name="com.XXXX.YYYY" />
</intent-filter>
</receiver>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:launchMode="singleTask" android:screenOrientation="landscape">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" />
<!-- replace #drawable/push_icon with your push icon identifier -->
<meta-data android:name="com.parse.push.notification_icon" android:resource="#drawable/app_icon"/>
</application>
</manifest>
Please, replace com.XXXX.YYYY by -your- bundle identifier, in case of thetnswe would be by com.JoyDash.Movies
(funny thing: there is no GCM BroadcastReceiver as the Parse Push samples says, it was spitting errors like this error setting up push notification using parse.com and android studio)
And then I have a C# Unity Script in one of my GameObjects (actually the same than the one I use to initialize Parse):
using UnityEngine;
using System.Collections;
using Parse;
public class ParsePushRegistration : MonoBehaviour {
// Use this for initialization
void Start () {
#if UNITY_ANDROID
ParsePush.ParsePushNotificationReceived += (sender, args) => {
AndroidJavaClass parseUnityHelper = new AndroidJavaClass ("com.parse.ParseUnityHelper");
AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject> ("com.unity3d.player.UnityPlayerNativeActivity");
// Call default behavior.
parseUnityHelper.CallStatic ("handleParsePushNotificationReceived", currentActivity, args.StringPayload);
};
#endif
}
}
Hope it helps! If not, let me know... and we will see :)

Resources