I have been trying to add Apple MusicKit auth SDK to an android app, I have added the AAR provided by apple and the necessary step to initialize the auth flow, but the SDK just redirects me to the google play store listing of apple music, I do have the app installed and logged in on my test device.
Apple MusicKit Auth SDK : musickitauth-release-1.1.2.aar
Here's the piece of code I use to init the auth flow :
val intent = authenticationManager.createIntentBuilder(BuildConfig.APPLE_DEV_TOKEN)
.setHideStartScreen(true)
.setStartScreenMessage("Connect with Apple Music")
.build()
startActivityForResult(intent , Const.APPLE_REQ_CODE)
Here's the ActivityRequest Code :
val result = authenticationManager.handleTokenResult(data)
if (result.isError) {
val error = result.error
Alerts.log(TAG , "APPLE ERROR: $error")
}
else {
Alerts.log(TAG , "APPLE TOKEN: ${result.musicUserToken}")
}
This is what I get in my logs :
D/SDKUriHandlerActivity: onCreate: DEV_TOKEN_HERE
D/AuthUtils: deeplinkAppleMusic: uri = musicsdk://applemusic/authenticate-v1?appPackage=PACKAGE_ID&devToken=DEV_TOKEN_HERE
W/System.err: android.content.pm.PackageManager$NameNotFoundException: com.apple.android.music
W/System.err: at android.app.ApplicationPackageManager.getPackageInfoAsUser(ApplicationPackageManager.java:244)
W/System.err: at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:213)
W/System.err: at com.apple.android.sdk.authentication.a.a(AuthSDK:92)
W/System.err: at com.apple.android.sdk.authentication.a.b(AuthSDK:66)
W/System.err: at com.apple.android.sdk.authentication.a.b(AuthSDK:56)
W/System.err: at com.apple.android.sdk.authentication.SDKUriHandlerActivity.onCreate(AuthSDK:43)
W/System.err: at android.app.Activity.performCreate(Activity.java:8183)
W/System.err: at android.app.Activity.performCreate(Activity.java:8167)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1316)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3751)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3950)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2377)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:262)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8304)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
D/a: deeplinkAppleMusic: isAppleMusicInstalled(activity) = 2
W/System.err: android.content.pm.PackageManager$NameNotFoundException: com.apple.android.music
W/System.err: at android.app.ApplicationPackageManager.getPackageInfoAsUser(ApplicationPackageManager.java:244)
W/System.err: at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:213)
W/System.err: at com.apple.android.sdk.authentication.a.a(AuthSDK:92)
W/System.err: at com.apple.android.sdk.authentication.a.b(AuthSDK:67)
W/System.err: at com.apple.android.sdk.authentication.a.b(AuthSDK:56)
W/System.err: at com.apple.android.sdk.authentication.SDKUriHandlerActivity.onCreate(AuthSDK:43)
W/System.err: at android.app.Activity.performCreate(Activity.java:8183)
W/System.err: at android.app.Activity.performCreate(Activity.java:8167)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1316)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3751)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3950)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2377)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:262)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8304)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
D/AuthUtils: deeplinkAppleMusic: activityNotFound!
D/AuthUtils: sendMarketIntent : uri = musicsdk://applemusic/authenticate-v1?appPackage=PACKAGE_ID&devToken=DEV_TOKEN_HERE
D/AuthUtils: sendMarketIntent: uri = market://details?id=com.apple.android.music&referrer=musicsdk%3A%2F%2Fapplemusic%2Fauthenticate-v1%3FappPackage%3DPACKAGE_ID%26devToken%DEV_TOKEN_HERE
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@dd295ee[]
D/ViewRootImpl[SDKUriHandlerActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
There isn't much documentation for this anywhere, the apple site just refers to the code references and the AAR download site.
SDK Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.apple.android.sdk.authentication"
android:versionCode="1"
android:versionName="1.2.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="28" />
<application
android:allowBackup="true"
android:supportsRtl="true" >
<activity
android:name="com.apple.android.sdk.authentication.StartAuthenticationActivity"
android:screenOrientation="portrait"
android:theme="@style/MusicKitAuthTheme" >
</activity>
<activity
android:name="com.apple.android.sdk.authentication.SDKUriHandlerActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:exported="true"
android:theme="@style/MusicKitAuthTheme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="${applicationId}"
android:pathPattern="/authenticateresult.*"
android:scheme="musicsdk" />
</intent-filter>
</activity>
</application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="com.apple.android.music" />
</intent>
</queries>
</manifest>
from Apple MusicKit SDK in Android
No comments:
Post a Comment