From 679a90c29290194b455d112032742d98d09e7e2c Mon Sep 17 00:00:00 2001 From: gilshahar7 Date: Sun, 19 Feb 2017 03:11:53 +0200 Subject: [PATCH] Notifications now include the album artwork also, changed the title and message of the notification. (old was title = song name, message = artist) (new is title = now playing, message = song name \nby: artist) --- Tweak.xm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Tweak.xm b/Tweak.xm index 5e6ef0a..672b8f5 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -9,6 +9,7 @@ @property bool isPlaying; @property (nonatomic,readonly) NSString * nowPlayingAppDisplayID; @property (nonatomic,readonly) MPUNowPlayingMetadata * currentNowPlayingMetadata; + @property (nonatomic,readonly) UIImage * currentNowPlayingArtwork; @end @interface JBBulletinManager : NSObject @@ -24,6 +25,7 @@ %hook MPUNowPlayingController static NSString *cachedTitle; + static NSString *artist; -(void)_updateCurrentNowPlaying{ %orig; double delayInSeconds = 0.5; @@ -31,7 +33,16 @@ dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ if(self.isPlaying && ([self.nowPlayingAppDisplayID isEqualToString:@"com.apple.Music"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.spotify.client"]) && ![cachedTitle isEqualToString:self.currentNowPlayingMetadata.title]){ cachedTitle = [self.currentNowPlayingMetadata.title copy]; - [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:self.currentNowPlayingMetadata.title message:self.currentNowPlayingMetadata.artist bundleID:self.nowPlayingAppDisplayID]; + if([self.currentNowPlayingMetadata.artist length] > 1){ + artist = [NSString stringWithFormat: @"\nBy: %@", self.currentNowPlayingMetadata.artist]; + }else{ + artist = @""; + } + if(self.currentNowPlayingArtwork != nil){ + [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:@"Now Playing" message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingMetadata.title, artist] bundleID:self.nowPlayingAppDisplayID hasSound:false soundID:0 vibrateMode:0 soundPath:@"" attachmentImage:self.currentNowPlayingArtwork overrideBundleImage:nil]; + }else{ + [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:@"Now Playing" message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingMetadata.title, artist] bundleID:self.nowPlayingAppDisplayID]; + } } }); }