It is not a good idea but if your opponent is not very good then you can get away with it. A good player will punish you for playing this way. The only time i'd consider a sacrifice like this would be if I was way ahead in development and could launch an immediate attack. In the above example it just looks like a bad idea to me.
Minor piece sacrifice for castling rights
I guess there will always be a way to get that rook out from the corner. I guess I was just lucky.
Thanks for your advice!

In this position it is a poor choice, bishop for a pawn is generally a losing proposition without immediate positional gains which you lack here ,perhaps with a good follow up check leading to developing an undeveloped minor such a sacrifice might be considered but here i beleve the material lose to simply be losing

The bishop here was quite powerful controlling a strong diagonal , covering your white square weaknesses and representing the bishop pair in truth i believe this position to be lost except for tactical blunders, however based on the line your opponent played immediately following kxf7 the position was perhaps playable, at least against a weeker opponent with quick time controls
After black plays Be7, Rf8 and Kg8 he has castled manually. That is 3 moves, so if you cant get a bishop worth material before those 3 moves you are just one piece down.
So I was hoping to get some advice from a chess player much more seasoned than I. I've heard it's generally not worth exchanging a minor piece for castling rights - although it did make his King vulnerable in the center and his h8 rook didn't come into play for the remainder of the game.
The chess.com app game analysis indicated that this move was a "blunder", though it set me up well for the remainder of the game. Any thoughts/opinions on the matter would be very helpful!
NB. The game ended with black resignation on move 20.