During a commencement address to Duke University Sunday, Apple CEO Tim Cook used some well-known platitudes, telling the students to make brave choices, rise to challenges and be unafraid to break with conventional wisdom.

He also appeared take yet another jab at Facebook and its handling of user data.

"We reject the excuse that getting the most out of technology means trading away your right to privacy," Cook said. "So we choose a different path, collecting as little of your data as possible, being thoughtful and respectful when it's in our care because we know it belongs to you."

The comment echoed Cook's earlier criticism of Facebook, which has endured months of criticism after it was revealed that a political data analytics firm, Cambridge Analytica, was able to harvest data for nearly 90 million Facebook users.

"I wouldn't be in this situation," Cook told reporters from Recode and MSNBC in March.

Related: Mark Zuckerberg hits back at Tim Cook

"The truth is, we could make a ton of money if we monetized our customer — if our customer was our product," he said. "We've elected not to do that."

Cook also called for increased regulation of social media and questioned whether Facebook should monetize user data on its free platforms by selling targeted ads.

Facebook CEO Mark Zuckerberg shot back at Cook in an interview published by Vox last month.

"You know, I find that argument, that if you're not paying that somehow we can't care about you, to be extremely glib. And not at all aligned with the truth," Zuckerberg told Vox.

Cook on Sunday again aimed to paint Apple's (AAPL) handling of user data in stark contrast with Facebook's. He credited Apple co-founder Steve Jobs with instilling within the company the drive to do things better.

"In every way at every turn, the question we ask ourselves is not, 'What can we do?', but 'What should we do?" Cook said. "Because Steve taught us that's how change happens, and from him I learned to never be content with the way that things are."

Apple has had a few tangles with privacy issues as well.

Related: Tim Cook disses Amazon second headquarters search

The company caught flack when it announced in February a plan to move iCloud accounts registered in mainland China to state-run Chinese servers. Apple made the move after it unsuccessfully fought to be exempt from a controversial new cybersecurity law in the Asian nation, but the decision alarmed privacy advocates.

And in 2014, hackers were able to steal nude photos from celebrities' iCloud accounts.

After that, Apple committed to increased transparency, and the company encrypted iPhones to make it more difficult for anyone — even authorities — to get their hands on data.

Cook, who often weighs in on social issues, also used his platform at Duke University to praise the "fearless" women who have spoken out in the #MeToo movement, the Parkland student advocating for tighter gun control, and people who "fight for the rights of immigrants."

— CNN's Sherisse Pham, David Goldman and Seth Fiegerman contributed to this report.