Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

fix: background Music Haptics finds songs outside the US catalog and cannot hang Spotify at launch

My-Name-Is-Jefff70d37ed8647
diff --git a/README.md b/README.md
index fc60bf37..c4e5852c 100644
--- a/README.md
+++ b/README.md
@@ -47,8 +47,8 @@ to Spotify's own screens with everything else the mod adds on top. Both live in
No IPA is distributed. Bring a decrypted **Spotify 9.1.78** IPA; you get an unsigned
`vitrine-<mod version>.ipa` to sign with SideStore, Feather or any certificate signer. The release's `.deb`
-is the tweak alone: injected by hand, it misses the app changes the redesign needs (its glass tab bar) and
-the Live Activity, so build the IPA instead.
+is the tweak alone: injected by hand, it misses the app changes the redesign needs (its glass tab bar), the Live Activity
+and Music Haptics in the background, so build the IPA instead.
### Build with GitHub Actions
diff --git a/docs/tweaks.md b/docs/tweaks.md
index ae9e4dda..2fdc904d 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -302,7 +302,7 @@ Shared:
the taps and the rumble for when the sound is heard, at their strength and leaving out what Follows
leaves out (MusicHaptics.x). Everything applies at once; nothing plays while Spotify is not the active
app. Beside it, In the Background (iOS 18 and up) asks Spotify's extended-metadata for the track's
- ISRC with Spotify's own spclient headers, asks Apple Music's catalog for that ISRC, and names the
+ ISRC with Spotify's own spclient headers, asks Apple Music's catalog for that ISRC (the phone's own country first, then the US), and names the
matched song's catalog id (same ISRC, length within 2 s, a haptic track) or else the ISRC in the now
playing info for iOS's own Music Haptics, which plays on the lock screen and in other apps too
(SystemMusicHaptics.x, its pure steps in SGHapticTrack.m). Both may be on: while it asks and while
diff --git a/tweak/Sources/App/Onboarding/Environment.m b/tweak/Sources/App/Onboarding/Environment.m
index 5e4bd6f4..40220211 100644
--- a/tweak/Sources/App/Onboarding/Environment.m
+++ b/tweak/Sources/App/Onboarding/Environment.m
@@ -41,7 +41,8 @@ static SGProblem version(void) {
}
// Installed without the app changes Vitrine's IPA build makes (scripts/pipeline.sh: plist/liquid-glass.plist and the
-// Live Activity), as when its .deb is injected by hand: the system keeps its old bars, so the glass tab bar is gone.
+// Live Activity), as when its .deb is injected by hand: the system keeps its old bars, so the glass tab bar is gone, and
+// without MusicHapticsSupported iOS leaves Spotify out of Music Haptics.
static BOOL withoutAppChanges(void) {
id compatibility = [NSBundle.mainBundle objectForInfoDictionaryKey:@"UIDesignRequiresCompatibility"];
return SGRedesignAvailable() && SGRedesignedUIStored() && !([compatibility isKindOfClass:NSNumber.class] && ![compatibility boolValue]);
@@ -49,7 +50,7 @@ static BOOL withoutAppChanges(void) {
static SGProblem appChanges(void) {
return @[@"Installed without Vitrine's app changes",
- @"The redesign needs changes to the app that only Vitrine's IPA build makes, so the tab bar stays Spotify's own and the Live Activity is missing. Build the IPA with Vitrine instead of injecting its .deb."];
+ @"The redesign needs changes to the app that only Vitrine's IPA build makes, so the tab bar stays Spotify's own, the Live Activity is missing, and iOS does not list Spotify for Music Haptics, which stops vibrations in the background. Build the IPA with Vitrine instead of injecting its .deb."];
}
static SGProblem fellBack(void) {
diff --git a/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m b/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m
index 4997992d..6e168716 100644
--- a/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m
+++ b/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m
@@ -7,7 +7,6 @@
static NSString *const kTokenKey = @"spotifyglass.motion.token";
static NSString *const kBrowse = @"https://music.apple.com/us/browse";
static NSString *const kSearch = @"https://amp-api.music.apple.com/v1/catalog/us/search";
-static NSString *const kSongs = @"https://amp-api.music.apple.com/v1/catalog/us/songs";
static NSString *const kSafari = @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15";
// A token this close to its expiry is read again rather than used.
static const NSTimeInterval kTokenMargin = 3600;
@@ -479,8 +478,20 @@ void SGMotionSongsWithISRC(NSString *isrc, void (^done)(NSArray *songs)) {
return;
}
lookUp([@"isrc\n" stringByAppendingString:isrc], done, ^(void (^answer)(id, BOOL)) {
+ // The phone's own country first, as Apple sells some recordings only there; then the US catalog.
+ NSString *region = NSLocale.currentLocale.countryCode.lowercaseString;
+ if (![region rangeOfString:@"^[a-z]{2}$" options:NSRegularExpressionSearch].length) region = @"us";
// filter[isrc] and fields[songs], the brackets escaped: iOS before 17 makes no URL of them bare.
- NSString *address = [NSString stringWithFormat:@"%@?filter%%5Bisrc%%5D=%@&fields%%5Bsongs%%5D=isrc,durationInMillis,hasHaptics", kSongs, escaped(isrc)];
- askCatalog(address, @"data", YES, ^(NSArray *found, BOOL answered) { answer(found, answered); });
+ NSString *(^addressIn)(NSString *) = ^NSString *(NSString *storefront) {
+ return [NSString stringWithFormat:@"https://amp-api.music.apple.com/v1/catalog/%@/songs?filter%%5Bisrc%%5D=%@&fields%%5Bsongs%%5D=isrc,durationInMillis,hasHaptics",
+ storefront, escaped(isrc)];
+ };
+ askCatalog(addressIn(region), @"data", YES, ^(NSArray *found, BOOL answered) {
+ if (found.count || [region isEqualToString:@"us"]) {
+ answer(found, answered);
+ return;
+ }
+ askCatalog(addressIn(@"us"), @"data", YES, ^(NSArray *inUS, BOOL answeredInUS) { answer(inUS, answeredInUS); });
+ });
});
}
diff --git a/tweak/Sources/Shared/Haptics/SystemMusicHaptics.x b/tweak/Sources/Shared/Haptics/SystemMusicHaptics.x
index fff0b1f7..76594782 100644
--- a/tweak/Sources/Shared/Haptics/SystemMusicHaptics.x
+++ b/tweak/Sources/Shared/Haptics/SystemMusicHaptics.x
@@ -281,11 +281,15 @@ API_AVAILABLE(ios(18.0))
SGAddPlayerStateObserver(native);
NSNotificationCenter *center = NSNotificationCenter.defaultCenter;
void (^changed)(NSNotification *) = ^(NSNotification *note) { [native systemChanged]; };
- [center addObserverForName:MAMusicHapticsManagerActiveStatusDidChangeNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:changed];
+ // iOS's own may come from any thread: heard there and handed to main without waiting (AGENTS.md).
+ void (^changedFromAnywhere)(NSNotification *) = ^(NSNotification *note) {
+ dispatch_async(dispatch_get_main_queue(), ^{ [native systemChanged]; });
+ };
+ [center addObserverForName:MAMusicHapticsManagerActiveStatusDidChangeNotification object:nil queue:nil usingBlock:changedFromAnywhere];
// Not in the SDK's headers, though MediaAccessibility exports it: posted as the switch in Accessibility moves.
void *enabledName = dlsym(RTLD_DEFAULT, "MAMusicHapticsEnabledStatusDidChangeNotification");
id name = enabledName ? (__bridge id)*(void **)enabledName : nil;
- if ([name isKindOfClass:NSString.class]) [center addObserverForName:name object:nil queue:NSOperationQueue.mainQueue usingBlock:changed];
+ if ([name isKindOfClass:NSString.class]) [center addObserverForName:name object:nil queue:nil usingBlock:changedFromAnywhere];
[center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:changed];
// Only In the Background's own flip: Music Haptics' would take iOS's identifier off for nothing.
__block BOOL background = SGMusicHapticsInBackground();