【发布时间】:2020-12-14 05:59:55
【问题描述】:
我有这个应用程序,我想从我的管理面板发送推送通知。我认为我做的一切都很好,但是 OneSignal 仅在我将其安装在我的模拟器中时才会检测到我的应用程序已安装,但是当我在手机上安装 apk 时,它不会检测到这一点。我有一部安卓 10 手机。这是我的文件:
build.cradle(应用程序):
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.8, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId 'ga.nabukoapps.materialwallpaper'
manifestPlaceholders = [onesignal_app_id: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName '1.0'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
implementation 'com.google.android.gms:play-services-ads:19.3.0'
implementation 'com.google.android.ads.consent:consent-library:1.0.8'
implementation 'com.balysv:material-ripple:1.0.2'
//noinspection GradleDependency
implementation 'com.onesignal:OneSignal:[3.15.0, 3.99.99]'
//implementation 'com.onesignal:OneSignal:3.11.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.bogdwellers:pinchtozoom:0.1'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.karumi:dexter:4.2.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'commons-io:commons-io:2.4'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
}
apply plugin: 'com.google.gms.google-services'
build.cradle(项目):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
【问题讨论】:
-
我假设您已按照以下说明进行操作:documentation.onesignal.com/docs/android-sdk-setup 您是否尝试在几种不同的真实设备上安装该应用程序?也许您的设备在使用 Google Play 服务方面存在问题?
-
您也可以尝试在您的项目中包含一个 google-services.json,用于与 OneSignal 一起使用的 Firebase APi 密钥。还有一件事,我不确定您是否需要
apply plugin: 'com.google.gms.google-services'- 也许它会破坏某些东西。 -
我已将其包含在我的项目中。
标签: android firebase android-studio google-play-services onesignal